im programming a clone of arkanoid/breakout. my biggest problems are collision detection and the movement of the ball.
up to now im handling the movement like this:
for a clean collision detection the ball movement is calculated several times a frame (+collision detection) and then drawed. so if the ball has a speed of 5, his way is calculated 5 times and then drawed to the screen.
with this technique he flies fast enough for the human eye but is calculated exactly and doesnt jum in 5 pixel steps.
but i dont think, it is the best way to move him.
im doing it this way because of the following problem :
if i would only calculate, where the ball has to be drawn next frame and he is very fast (e.g. x+=7, y+=7) then it could be that he “jumps” over an object with which he should collide. so i try in my method to calculate every step in between.
now my second big problem:
i find it very easy to handle if i command the direction of the ball by passing him an angle as parameter, so i wrote this movement calculating routine :
dir_x = Math.cos(alpha*(Math.PI/180));
dir_y = Math.sin(alpha*(Math.PI/180));
....
ball.pos_x+=dir_x ...
ball.pos_y+=dir_y ...
alpha is my angle parameter, dir-vars are double
for my method of movement i have to be sure that this formula calculates a line-path without gaps (so that the ball wont jump)
i have many further questions, but i want to know, if my way could be improved =)