My code checks if the ball hit the top of the screen, and if so, negates the speed of the ball (sending it the other way)
Am I doing something wrong?
Advertising
crait wrote:Do you mind posting the code for your collision of the top of the screen? A number of popular issues come to mind when hearing this.
Code: Select all
if((ball.y + ball.radius) > SCREEN_H)
{
ball.y = (SCREEN_H - ball.radius);
ySpeed = -ySpeed;
}
You should definitely be using a signed int for negative numbers.John Dupe wrote:crait wrote:Do you mind posting the code for your collision of the top of the screen? A number of popular issues come to mind when hearing this.ball is an object of a typdef struct called circle.Code: Select all
if((ball.y + ball.radius) > SCREEN_H) { ball.y = (SCREEN_H - ball.radius); ySpeed = -ySpeed; }
ySpeed is a uint32_t set to either 5 or -5.