Advertisement
jabela

8 moving car 1b

Dec 19th, 2015
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. #objects
  2. car1 = car([370,430])
  3.  
  4. #The Loop
  5. while running:
  6.     for event in pygame.event.get():
  7.         if event.type == pygame.QUIT:
  8.             running = False
  9.     if event.type == pygame.KEYDOWN:
  10.             if event.key == pygame.K_LEFT:
  11.                 car1.x_change = -5
  12.             elif event.key == pygame.K_RIGHT:
  13.                 car1.x_change = 5
  14.     if event.type == pygame.KEYUP:
  15.         if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
  16.             car1.x_change = 0
  17.     car1.x += car1.x_change
  18.     window.fill((0, 0, 0))
  19.     window.blit(car1.image,[car1.x,car1.y])
  20.     pygame.display.update()
  21.     clock.tick(60)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement