Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #When roadblock gets to the bottom put back to the top & add to score
- if randy > 570:
- randy = -100
- randx = random.randrange(0, 300)
- score = score + 1
- print(score)
- #move the roadblock down
- randy = randy + 5
- #change the car position
- car1.x += car1.x_change
- window.fill((0, 0, 0))
- #draw the roadblock
- rect1 = pygame.draw.rect(window, (255, 255, 0),(randx, randy, 100, 30))
- #draw the car
- window.blit(car1.image,[car1.x,car1.y])
- #Make an invisible rectangle around the car for crash detection.
- rect2 = pygame.Rect(car1.x,car1.y,70,150)
- #Draw the screen
- pygame.display.update()
- #Check to see if the rectangles have crashed
- if rect2.colliderect(rect1):
- print('crash')
- running = False
- clock.tick(60)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement