teromakotero

Python_from_Scratch_07_ratkaisu

May 13th, 2019
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. import turtle
  2. import background
  3. import time
  4. import random
  5.  
  6. pycat = turtle.Turtle()
  7. pycat.hideturtle()
  8. screen = turtle.Screen()
  9. image = ()
  10. image = ["pycat_small_left.png","pycat_2_left_small.png","Angelo-Gemmi-stone_100_px_left.png"]
  11. screen.addshape(image[0])
  12. pycat.shape(image[0])
  13. pycat.penup()
  14. pycat.goto(-150,0)
  15. pycat.showturtle()
  16. pycat_2 = turtle.Turtle()
  17. pycat_2.hideturtle()
  18.  
  19. stone = turtle.Turtle()
  20. stone.hideturtle()
  21. screen.addshape(image[2])
  22. stone.shape(image[2])
  23. stone.penup()
  24. stone.goto(random.randrange(10,150,20),0)
  25. stone.showturtle()
  26.  
  27. screen.addshape(image[1])
  28. pycat_2.shape(image[1])
  29. pycat_2.penup()
  30. pycat_2.goto(-140,0)
  31. pycat_2.hideturtle()
  32.  
  33. # KIRJOITA TÄMÄN RIVIN ALAPUOLELLE OMA KOODISI
  34. kivi_x = stone.xcor()
  35. while True:
  36.   if(pycat.xcor() == kivi_x - 80):
  37.     pycat.write("Kivi!")
  38.     break
  39.   pycat_2.showturtle()
  40.   pycat.hideturtle()
  41.   pycat.forward(20)
  42.   time.sleep(0.5)
  43.   pycat.showturtle()
  44.   pycat_2.hideturtle()
  45.   pycat_2.forward(20)
  46.   time.sleep(0.5)
Advertisement
Add Comment
Please, Sign In to add comment