Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Ball {
- Vector2 velocity = new Vector2();
- Vector2 position = new Vector2();
- Vector2 movement = new Vector2();
- Vector2 touch = new Vector2();
- Vector2 dir = new Vector2();
- float speed = 100;
- private int width;
- private int height;
- public Ball(float x, float y, int width, int height)
- {
- this.width = 10;
- this.height = 10;
- position = new Vector2(x,y);
- velocity = new Vector2(0,0);
- }
- public void update(float delta)
- {
- //velocity.add(acceleration.cpy().scl(delta));
- /*
- if (velocity.y > 200)
- { velocity.y = 200 }
- */
- position.add(movement);
- movement.set(velocity).scl(delta);
- }
- public void onClick() {
- dir.set(touch).sub(position).nor();
- velocity = new Vector2(dir).scl(speed);
- }
- public float getX() {
- return position.x;
- }
- public float getY() {
- return position.y;
- }
- public float getWidth() {
- return width;
- }
- public float getHeight() {
- return height;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement