Advertisement
progrmor

Untitled

May 12th, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. class Enemy {
  2.  
  3. private Ball ball;
  4.  
  5. Vector2 positionTwo = new Vector2();
  6. Vector2 velocityTwo = new Vector2();
  7. Vector2 movementTwo = new Vector2();
  8. Vector2 targetTwo = new Vector2();
  9. Vector2 dirTwo = new Vector2();
  10.  
  11. private float width;
  12. private float height;
  13. float speed = 50;
  14.  
  15. public Enemy (float x, float y)
  16. {
  17. positionTwo.set(x, y);
  18. targetTwo.set(x,y);
  19. this.width = 5;
  20. this.height = 5;
  21.  
  22. }
  23.  
  24. public float getWidth() {
  25. return width;
  26. }
  27.  
  28. public float getHeight() {
  29. return height;
  30. }
  31.  
  32. public void update (float deltaTime) {
  33.  
  34. movementTwo.set(velocityTwo).scl(deltaTime);
  35. if (positionTwo.dst2(targetTwo) > movementTwo.len2()) {
  36. positionTwo.add(movementTwo);
  37. } else {
  38. positionTwo.set(targetTwo);
  39. }
  40.  
  41.  
  42. }
  43.  
  44. public void moveTo (float x, float y) {
  45. dirTwo.set(targetTwo.set(x,y)).sub(positionTwo).nor();
  46. velocityTwo.set(dirTwo).scl(speed);
  47.  
  48. }
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement