UDP Pong - Game Mechanics

As stated before, Pong really is the "Hello, World!" of game development.  I'm pretty sure that most of you have done it at some point, but I chose to handle it slightly differently, so I think it's fair to go over what needs to happen.

 

Scoring

If the Ball hits the left side of the screen, it's a score for the right side player.  And vice-versa if the Ball touches the right side.  The Ball should then reset to the center of the screen.  A "score," noise should also be played.

 

Key Presses

This only applies to the Client application.  If a user presses the Esc key at any time, it will close the application and notify the Server.  The Up and Down arrow keys will be used by the user to control the position of the Paddle.

 

Hitting Top & Bottom Bounds

If the Ball hits the top or the bottom of the screen it should flip the Y component of its velocity.  It's speed will also slightly increase by a random amount and a "ballHit," sound should be played.

 

Hitting the Paddles

Each Paddle has three collision areas.  One on the top, one on the bottom, and one in the middle (called it's "Front,").  If the Ball hits any of these its speed will increase slightly and its X direction will be flipped (a sound will also play too).  But if the top or the bottom collision areas are hit, it will also flip the Y component of the Ball's velocity.  Below is a diagram of the hitboxes:

 

Ball & Paddle Hitboxes

© 16BPP.net – Made using & love.
Back to Top of Page
This site uses cookies.