SHARE
TWEET

turtle traffic 16

faefgagfrasdasfwe May 26th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. start_ground = codesters.Rectangle(0, -250, 500, 50, "lightgreen")
  2. stage.disable_all_walls()
  3.  
  4. speedy = codesters.Sprite("turtle1", 0, -240)
  5. speedy.set_size(.2)
  6. speedy.turn_left(90)
  7.  
  8. x = -200
  9. for counter in range(5):
  10.     end_ground = codesters.Sprite("lilypad", x, 230)
  11.     x += 100
  12.  
  13. y = -150
  14. for counter in range(4):
  15.     road = codesters.Rectangle(0, y, 500, 60, "gray")
  16.     road.set_opacity(.2)
  17.     y += 100
  18.  
  19. def make_car():
  20.     img_list = ["car1", "car2"]
  21.     car_img = random.choice(img_list)
  22.     road_list = [-150, -50, 50, 150]  
  23.     rand_y = random.choice(road_list)
  24.     if rand_y == -150 or rand_y == 50:
  25.         car = codesters.Sprite(car_img, -400, rand_y)
  26.         car.turn_right(90)
  27.         car.set_size(.5)
  28.         car.set_x_speed(2)
  29.     if rand_y == -50 or rand_y == 150:
  30.         car = codesters.Sprite(car_img, 400, rand_y)
  31.         car.turn_left(90)
  32.         car.set_size(.5)
  33.         car.set_x_speed(-2)
  34.        
  35.  
  36. def interval():
  37.     make_car()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top