Heyo!
I’m starting to create games on iOS and I’m trying a Breakout-clone for start. As practice I wanted a ball to bounce around in a rectangle so I get my head around simple collision, direction and velocity.
My ball got the following:
Point position; // x, y
float direction;
float velocity;
In my “update” function, I want to move the ball in the current direction. What is the next position considering the velocity and direction?
Are there any helpers in some built-in frameworks in iOS?
I would really like to learn more about 2D-math so if someone got some reasources I would really appreciate if you send me a link.
Note that velocity already has direction; it is a vector
Bearing that in mind, your new position is:
Make velocity a CGPoint and make your direction variable redundant.