Advertisement
progrmor

Untitled

May 11th, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. public class Ball {
  2.  
  3. Vector2 velocity = new Vector2();
  4. Vector2 position = new Vector2();
  5. Vector2 movement = new Vector2();
  6.  
  7.  
  8.  
  9.  
  10. Vector2 touch = new Vector2();
  11. Vector2 dir = new Vector2();
  12.  
  13. float speed = 100;
  14.  
  15. private int width;
  16. private int height;
  17.  
  18.  
  19.  
  20. public Ball(float x, float y, int width, int height)
  21. {
  22. this.width = 10;
  23. this.height = 10;
  24. position = new Vector2(x,y);
  25. velocity = new Vector2(0,0);
  26.  
  27.  
  28. }
  29.  
  30. public void update(float delta)
  31. {
  32.  
  33.  
  34. //velocity.add(acceleration.cpy().scl(delta));
  35.  
  36. /*
  37. if (velocity.y > 200)
  38. { velocity.y = 200 }
  39. */
  40. position.add(movement);
  41. movement.set(velocity).scl(delta);
  42.  
  43. }
  44.  
  45. public void onClick() {
  46. dir.set(touch).sub(position).nor();
  47. velocity = new Vector2(dir).scl(speed);
  48. }
  49.  
  50.  
  51.  
  52. public float getX() {
  53. return position.x;
  54. }
  55.  
  56. public float getY() {
  57. return position.y;
  58. }
  59.  
  60. public float getWidth() {
  61. return width;
  62. }
  63.  
  64. public float getHeight() {
  65. return height;
  66. }
  67.  
  68.  
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement