User manual
too fast.
PONG – SOMEHOW
DIFFERENT
The next programming example is about the famous game Pong, but probably a
bit different than you may know it. Rather than using one of the paddles, you are
influencing the ball by using the directional buttons. Along the way, you are also
learning about some new elements of game programming.
Pong was released by Atari in 1972 and is one of the best known games ever. It is
based on the game of ping pong or table tennis. The classic version involves two
players playing against each other. On either side of a virtual playing field is a
paddle in the form of a dash. A ball now moves across the screen, and the player
must try to counter the ball with his paddle and return it to the opponent. If he fails
to do this, the opponent scores a point.
In this version you will take up the role of the ball while the two paddles are con-
trolled by the computer. You must try to keep the ball in the game for as long as
possible.
Open the program example by clicking on:
File -> Examples -> GameEngine -> GameEngine1 -> Pong
This program contains a lot, which you are already familiar with. Also, this time we
have the drawBall() function, which, depending on the current position, draws a
ball on the playing field. Analogously there are the drawPlayer() and drawField()
functions which will draw the two paddles on the display. The drawField() is a new
function, namely drawValue(), which draws the current level or score at a specified
position. The current level will change whenever the ball is hit successfully. This is
checked by means of the moveBall() function.
001
void moveBall() {










