Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. private double angle;
  2. public Bullet(int xx, int yy, int x, int y,Gun gun, int id, double angle) {
  3. this.x = xx;
  4. this.y = yy;
  5. tx = x;
  6. ty = y;
  7. xorg = xx;
  8. yorg = yy;
  9. this.gun = gun;
  10. this.id = id;
  11. this.angle = angle;
  12.  
  13.  
  14. try {
  15. image = new MImage(ImageIO.read(new File("PATH")));
  16. } catch (IOException e) {
  17. // TODO Auto-generated catch block
  18. e.printStackTrace();
  19. }
  20. image.rotateBy((int)Math.toDegrees(angle));
  21.  
  22. stopwatch.start();
  23. }
  24.  
  25.  
  26.  
  27. private int speed = 3,time = 0;;
  28. public void update() {
  29.  
  30.  
  31. double speedy, speedx;
  32. speedy = speed * Math.sin(Math.toRadians(angle));
  33. speedx = speed * Math.cos(Math.toRadians(angle));
  34.  
  35. y = (int) ((-5) * time * time + speedy * time + yorg);
  36. x = (int) (speedx * time + xorg);
  37. time++;
  38.  
  39. System.out.println(y + " --- " + x);
  40. if(stopwatch.getElapsedTime() > 500) {
  41. terminate(id);
  42. }
  43. }
  44.  
  45. public boolean shoot(int x, int y, int tx, int ty) {
  46. boolean worked = false;
  47. if(amo >= 0) {
  48. bullets.add(new Bullet(x,y,tx,ty,this,bullets.size(),Math.atan2(ty-y,tx-x)));
  49. amo --;
  50. worked = true;
  51. }
  52. return worked;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement