Activity 1 - Define the width of the Pong screen

Activity 1

You can adjust the boundary of the Pong game by adjusting the height and width of the rectangle that represents the boundary.

Go to the code containing the Pong game. Press run. Notice that the game’s boundary doesn’t look right - see the image below. Let’s fix this in this activity, so the game boundary looks good.

Pong game with incorrect boundary

Find // TODO (ACTIVITY 1) in the code. Modify the WIDTH attribute of Pong class. If you did this correctly, the boundary problem will be fixed. Press run and observe the result.

Try changing the values for height and width to see the effects of different values on the game’s boundary.

Takeaway

You have just modified one of the attributes in Pong class to influence how the game will look on screen.