nawamkihafahd

Untitled

Dec 14th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. package RedHazard;
  2.  
  3.  
  4. import java.awt.Color;
  5. import java.awt.Graphics;
  6. public class Ship
  7. {
  8. public int x, y, width = 35, height = 35;
  9. public int score;
  10. public Ship(Redhazard a)
  11. {
  12. this.x = 0;
  13. this.y = 600;
  14. }
  15. public void render(Graphics g)
  16. {
  17. g.setColor(Color.BLUE);
  18. g.fillRect(x, y, width, height);
  19. }
  20. public void move(boolean left)
  21. {
  22. int speed = 10;
  23. if(left)
  24. {
  25. if(x - speed > 0)
  26. {
  27. x-=speed;
  28. }
  29. else
  30. {
  31. x = 0;
  32. }
  33. }
  34. else
  35. {
  36. if(x + width + speed < 700)
  37. {
  38. x += speed;
  39. }
  40. else
  41. {
  42. x = 700 - width;
  43. }
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment