Hi all,
I'm currently trying to create my own version of Breakout/Pong using AppGameKit v2, and a problem I'm having is that I can't get the ball to reverse its direction properly.
This is how I'm handling movement now... (ball.sx stands for "speed x", same for ball.sy)
Rem Bounce the ball back
If GetSpriteX(ball.ID)/2 - 8 < GetSpriteX(bricks[x].ID)/2 or GetSpriteX(ball.ID)/2 + 8 > GetSpriteX(bricks[x].ID)/2
ball.sx = -ball.sx - speed_increase
ElseIf GetSpriteY(ball.ID)/2 + 8 > GetSpriteY(bricks[x].ID)/2 or GetSpriteY(ball.ID)/2 - 8 < GetSpriteY(bricks[x].ID)/2
ball.sy = -ball.sy - speed_increase
EndIf
It works for the most part, except that it will NEVER execute the "reversal" code for the y movement of the ball, only the x movement, but what it does execute is flawless and works as expected.
It occurred to me that if I could store the movement in some kind of vector, this would be a lot easier - all I would have to do then is say something like:
moveVector = -moveVector + speed_increase, which could go underneath the if-then statement of course. But I would still have the problem of determining which side of the brick the ball hit but that's relatively easy!
I tried searching the documentation but I found nothing about 2D vectors, just ones for 3D. Does anybody have any solutions?
I would love to get this game working, I'm very determined to complete it! I'm so close but so far at the same time.
Edited for typos...
It's back, baby!