I'm pretty new to Game maker, and i'm having some trouble with a function.
I'm making a pong-like game, and i'm running into an issue when the ball colides with the top of the paddle or the bottom (the smaller sides, not face on) the ball and paddle freeze.
The only code I have in the collision event of the ball with the paddle is to reverse the horizontal speed.
hspeed *= -1;
i understand the problem, that because the ball has made contact with the top, the horizontal direction reverses, but its still in contact with the surface as the veritcal speed hasn't changed so reverses again, and gets stuck in an infinite loop.
I've tried many things to work around it, such as setting an alarm to detect if the ball is still touching after one frame and to reverse the vertical speed ( no success)
I've also tried to make a check to see if the y position of the top of the ball is the same as the y position of the bottom of the paddle (and vice versa) and to reverse the vertical speed if true. but again no success.
i'm sure both these methods work if the correct code is used, but i must just be executing it wrong.
What method should i use to make it so that if the ball collides with the top or bottom of the paddle, it doesn't get stuck, and ideally just reverses the vertical speed instead of the horizontal speed?
i'm sure this has a simple solution but cause i'm new i cant work it out!
thanks!