You are viewing a single comment's thread from:
RE: Making an Android game in three hours
Very good game, very nice, pls upvote me Im totally not a hindu bot.
But seriously the paddles should be horizontal, and you could use the lower edge of screen as "board" while goingout on the sides gives points.
Yeah, ideally, I should also make sure that the ball hit the table exactly once before any of the players hit it as well. Pls upvote me too, I'm also totally not a hindu bot.
How did you manage the "AI"? All i did is take the vertical velocity of the ball minus 5 xD It is hard to score but possible :D
Once the ball falls below the top of the net on the bot's side, the bot racket's yVelocity is given by wantedBallYVelocity+ballYvelocity (where ballYVelocity is a negative number). This ensures that the ball always bounces up with a yVelocity given by wantedBallYVelocity. The yVelocity will vary slightly, though, since the inertia defined for the racket limits how quickly it can accelerate.
When it comes to the racket's xVelocity, it actually just matched that of the ball, which was actually a problem after I introduced air resistance. If the player did not hit the ball enough sideways, it might actually stop moving sideways, causing the bot to just bounce it up and down. I solved this by always moving the bot's racket slightly towards the net right before the ball hit the racket. This ensures that the bot will always move the ball towards the net and eventually get it over.