Advertisement
Guest User

Bullet

a guest
Mar 16th, 2013
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. package OurGame;
  2.  
  3. import java.awt.*;
  4.  
  5. import javax.swing.ImageIcon;
  6.  
  7. public class Bullet {
  8.  
  9. int x, y;
  10. Image img;
  11. boolean visible = true;
  12.  
  13. public Bullet(int startX, int startY)
  14. {
  15. x = startX;
  16. y = startY;
  17. ImageIcon newBullet = new ImageIcon("bullet.png");
  18. img = newBullet.getImage();
  19. visible = true;
  20. }
  21.  
  22. public Rectangle getBounds()
  23. {
  24. return new Rectangle(x,y, 44, 24);
  25. }
  26. public int getX()
  27. {
  28. return x;
  29. }
  30. public int getY()
  31. {
  32. return y;
  33. }
  34. public boolean getVisible()
  35. {
  36. return visible;
  37. }
  38. public Image getImage()
  39. {
  40. return img;
  41. }
  42.  
  43.  
  44. public void move()
  45. {
  46. x = x + 2;
  47. if ( x > 700)
  48. visible = false;
  49. }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement