Okay, so so far I got this:
1 2 3 4 5 6 7 8
| @Override public void update(GameContainer gc, int delta) throws SlickException { ball.position.add(ball.velo); ball.velo.add(ball.accel); ball.accel = ball.velo.scale(0.5f); } |
This is slowly moving this ball towards my paddle:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| public class Ball { int size = 30; float speed = 0.2f; float maxSpeed = 6; float angle; Vector2f position; Vector2f velo; Vector2f accel; public Ball(){ velo = new Vector2f(0,speed); position = new Vector2f(640/2 - size/2, 200); accel = new Vector2f(0,speed); } } |
But how would I apply my collision algorithm to this?