I wasn't sure whether to post in Micro Edition forum or not as this relates to my attempts to make a pong game for my phone. I'm trying to work my way through the simple games...if I can master Pong, Tetris will be next!
The problem I'm having is that I'm unsure as to how to get the ball to move at angles from a paddle once it strikes one.
Currently how I'm trying to do it is:
I've tried to get the ball to move by changing its x direction when it collides with a paddle (so dx = 1, then dx = -dx) but the ball does not move very realistically as it seems to always head back in the same direction after each collision.
I was thinking that I could check to see what section of the paddle the ball collided with and use that to pick which value to set dx as -1 / +1.
I'd be really grateful of any tips, I don't really want to go looking at other people's source code on the net.
Never trust a computer you can't throw out a window - Steve Wozniak
Keep track of the accelleration of the paddle and apply some extra dy or -dy. Kinda like adding spin to a serve in real ping pong.
Joined: Aug 14, 2007
Sorry for the long delay in replying, thanks a million for your suggestions. I got it working in the end by splitting the paddle up into 5 sections and if the ball hit one of the sections, I'd set it's return vector from a predefined list.