Advertisement
jabela

9 Roadblock 1C

Dec 20th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     #When roadblock gets to the bottom put back to the top & add to score
  2.     if randy > 570:
  3.         randy = -100
  4.         randx = random.randrange(0, 300)
  5.         score = score + 1
  6.         print(score)
  7.     #move the roadblock down
  8.     randy = randy + 5
  9.     #change the car position
  10.     car1.x += car1.x_change
  11.     window.fill((0, 0, 0))
  12.     #draw the roadblock
  13.     rect1 = pygame.draw.rect(window, (255, 255, 0),(randx, randy, 100, 30))
  14.     #draw the car
  15.     window.blit(car1.image,[car1.x,car1.y])
  16.     #Make an invisible rectangle around the car for crash detection.
  17.     rect2 = pygame.Rect(car1.x,car1.y,70,150)
  18.     #Draw the screen
  19.     pygame.display.update()
  20.     #Check to see if the rectangles have crashed
  21.     if rect2.colliderect(rect1):
  22.         print('crash')
  23.         running = False
  24.     clock.tick(60)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement