Advertisement
WorccroW

Tumatakbong Turtle

Aug 6th, 2022
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. import turtle
  2. import random
  3.  
  4. #********FIELDS********
  5. field = turtle.Turtle()
  6. field.up()
  7. field.goto(-100,100)
  8. field.down()
  9. field.speed(0)
  10.  
  11. for i in range(15):
  12. field.write(i)
  13. field.right(90)
  14. field.forward(200)
  15. field.right(180)
  16. field.forward(200)
  17. field.right(90)
  18. field.forward(25)
  19. #********FIELDS********
  20.  
  21. #********Players********
  22. #Determine Distance of Player
  23. x_player1 = 0
  24. x_player2 = 0
  25.  
  26. player1 = turtle.Turtle()
  27. player1.up()
  28. player1.color("red")
  29. player1.shape("turtle")
  30. player1.goto(-120,60)
  31.  
  32. player2 = turtle.Turtle()
  33. player2.up()
  34. player2.color("blue")
  35. player2.shape("turtle")
  36. player2.goto(-120,30)
  37.  
  38. player3 = turtle.Turtle()
  39. player3.up()
  40. player3.color("yellow")
  41. player3.shape("turtle")
  42. player3.goto(-120,0)
  43. #********Players********
  44.  
  45. win = input ("Which turtle will win:")
  46. text = turtle.Turtle()
  47. text.up()
  48. text.goto(-120,120)
  49. text.write("You think that the winner will be " + win)
  50.  
  51. finishLine = 395
  52. while True:
  53. step1 = random.randint(1,5)
  54. x_player1 = x_player1 + step1
  55. player1.forward(step1)
  56.  
  57. step2 = random.randint(1,5)
  58. x_player2 = x_player2 + step2
  59. player2.forward(step1)
  60.  
  61.  
  62. if x_player1 >= finishLine or x_player2 >= finishLine:
  63. break
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement