Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- gameExit = False
- pygame.init()
- gameDisplay = pygame.display.set_mode((800, 600))
- pygame.display.set_caption("game")
- car = pygame.image.load("car.png")
- clock = pygame.time.Clock()
- def process_keyboard(event):
- global car_x_shift
- if event.type == pygame.KEYDOWN:
- if event.key == pygame.K_LEFT:
- car_x_shift = -5
- if event.key == pygame.K_RIGHT:
- car_x_shift = 5
- if event.type == pygame.KEYUP:
- if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
- car_x_shift = 0
- def game_loop():
- global gameExit
- while not gameExit:
- for event in pygame.event.get():
- print(event)
- process_keyboard(event)
- if event.type == pygame.QUIT:
- gameExit = True
- quit()
- draw_object(car, car_x, car_y)
- pygame.display.update()
- clock.tick(30)
- game_loop()
- pygame.quit()
- quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement