Racket Ball :)


One of the first computer games was called Pong. It was an implementation of Ping Pong and was wildly popular years ago.  Today we are going to code a game with a similar feel to Pong, but a little less complicated.  Our game will be called Racket Ball (Yes, I know this is the wrong spelling.  It’s humor.)

Phase 1: The Paddle


For phase 1 of this project, you should create a graphics window with a paddle near the bottom that moves horizontally according to clicks of the arrow keys on the keyboard. When you finish, submit this code using this link.

Phase 2: The “Ball”


Introduce a bouncing square “ball” to your window.  Don’t worry about whether it hits the paddle or not.  Just have it bounce off of all the “walls”.  Submit this code when it is complete using this link.

Phase 3: Making Contact


Now that you have a paddle and a “ball” in place, we need to start implementing the object of the game, which is to keep the ball from hitting the floor. Please add the inRectangle() and squaresHit() functions (both from our notes) in your code so that the following situations are handled.

  1. If the “ball” hits the floor, display a message that the game is over and wait for the user to hit the “q” key.  Then quit the program.
  2. If the “ball” hits the paddle, turn it around, just as you did before when it hit the floor.  Later we will add some physics to the mix.

When you get these items working, submit your file using this link.

Phase 4: Keeping Score


Now that your game is functioning, it’s time to make it a competition.  For this phase of the program, we want to keep score.  For starters, let’s just make it simple.  Every time the ball bounces off the paddle, add one to the score.

You will need to make a Text object on your window.  Each time you add one to the score, use the setText() method to update the score in the window. Below is a screenshot of my version of the game.


And, here is a video clip of the entire thing in action.

When your program is working correctly and keeping score, please submit it using this link.

Phase 5: Style Points


Here are a few suggestions for improvements. If you think of others, please email them to me and I will add them to the list.

  • Add a pause key (“p”) that will freeze game play until another key is pressed.
  • Add a quit key (“q”) that will immediately quit the game, whether the ball has hit the floor or not.
  • Each time the score reaches a multiple of 5 (or another number) make the paddle shrink.
  • Each time the ball hits the paddle, increase the speed of the ball.
  • Adjust the angle of the ball depending on which half of the paddle it makes contact with.
  • Randomly generate the size of the original ball.
  • Add bumpers (obstacles) that deflect the ball.  When the bumpers is hit, move it to another location.
  • When the score reaches to, add a second ball to the game.

Show off your ideas to you classmates!

When your final masterpiece including style points is complete, please submit it using this link.