so the video will explain better than I can in words,
but the problem is that on the second rebound the ball bounces of the bottom wall then passes the side wall and disappears into the abyss never to be seen again lol
not sure why this is happening I have conditions in my code to check for this situation but doesn't seem to be working
ps it's only a simple console pong game nothing too fancy or complicated
Really suggest using a proper debugger, so that you can step through your code frame by frame, or pause the process as soon as something goes haywire. It can be really convenient.
Also, I would avoid global variables.
You'll notice your game only starts going haywire once score is > 1.
This corresponds to your line 189 if-block.
Inside this if-block, you increment ballx twice. This is in addition to where you either increment or decrement ballx in line 137's switch. You are doing ballx++ regardless of whether or not the ball is supposed to be going up, down, left, or right. Your ball is going to have a net direction of at least +1x even if it's supposed to be going -1x.
I suggest only updating the ball's position and direction in one unified place, once a frame.
Not in 2-3 different places.
n line 137's switch. You are doing ballx++ regardless of whether or not the ball is supposed to be going up, down, left, or right. Your ball is going to have a net direction of at least +1x even if it's supposed to be going -1x.
very good point that is a major problem,also I am trying to use a debugger but codeblocks is not having any of it the debugger keeps failing to open