Game Development Reference
In-Depth Information
which of the four diagonal directions the block is currently moving. On each iteration in
the game loop, we will adjust the X and Y position of the block in the Rect object. Also in
each iteration we will draw all the blocks on the screen at their current position. As the
program execution loops through the game loop, the blocks will gradually move across the
screen so that it looks like they are smoothly moving and bouncing around on their own.
Figure 17-7: The diagram of how blocks will bounce.
Creating and Setting Up Pygame and the Main Window
1. import pygame, sys, time
In this program, we also want to import the time module.
7. # set up the window
8. WINDOWWIDTH = 400
9. WINDOWHEIGHT = 400
10. windowSurface = pygame.display.set_mode((WINDOWWIDTH,
WINDOWHEIGHT), 0, 32)
Search WWH ::




Custom Search