Hardware Reference
In-Depth Information
if event.type == pygame.QUIT :
terminate()
if event.type == pygame.KEYDOWN :
if event.key == pygame.K_ESCAPE :
terminate()
if event.key == pygame.K_DOWN : ;
# expand / contract the box
updateBox(1,-2)
if event.key == pygame.K_UP :
updateBox(1,2)
if event.key == pygame.K_LEFT :
updateBox(0,-2)
if event.key == pygame.K_RIGHT :
updateBox(0,2)
if event.key == pygame.K_s :
rally = True
if event.key == pygame.K_SPACE :
pause = False
if event.key == pygame.K_q :
serve[0] = True
if event.key == pygame.K_HOME :
serve[1] = True
if event.key == pygame.K_PAGEDOWN :
if batY[1] < screenHeight - batInc :
batY[1] += batInc
if event.key == pygame.K_PAGEUP :
if batY[1] > batInc :
batY[1] -= batInc
if event.key == pygame.K_z :
if batY[0] < screenHeight - batInc :
batY[0] += batInc
if event.key == pygame.K_a :
if batY[0] > batInc :
batY[0] -= batInc
if __name__ == '__main__':
main()
Here more keyboard keys come into play. he Home key has been added for the right player's
serve key, along with the bat movement keys of Page Up and Page Down. he A, Q and Z keys
perform the same functions for the left player.
Search WWH ::




Custom Search