Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. window()
  2.  
  3. tfood = turtle.Turtle()
  4. tfood.hideturtle()
  5. tfood.pu()
  6. tfood.speed(0)
  7. tfood.shape("square")
  8. tfood.color("red")
  9.  
  10. tscore = turtle.Turtle()
  11. tscore.hideturtle()
  12. tscore.pu()
  13. tscore.speed(0)
  14. tscore.goto(100,-250)
  15. tscore.write("Score:" + str(a[0]), align="center",font=(10))
  16.  
  17. while x > -210 and x < 210 and y > -210 and y <210:
  18. if foodcoord[2] == 0:
  19. food(tfood)
  20. foodcoord[2] = 1
  21. turtle.onkey(u,"Up")
  22. turtle.onkey(l,"Left")
  23. turtle.onkey(r,"Right")
  24. turtle.onkey(d,"Down")
  25. turtle.listen()
  26. move()
  27. x = turtle.xcor()
  28. y = turtle.ycor()
  29. if x > foodcoord[0]*20-5 and x < foodcoord[0]*20+5 and y > foodcoord[1]*20-5 and y < foodcoord[1]*20+5:
  30. foodcoord[2] = 0
  31. tfood.clear()
  32. a[0] += 1
  33. tscore.clear()
  34. tscore.write("Score:" + str(a[0]), align="center",font=(10))
  35.  
  36. if len(cpos) > 1:
  37. for i in range(1,len(cpos)):
  38. if x < cpos[i][0]+5 and x > cpos[i][0]-5 and y < cpos[i][1]+5 and y > cpos[i][1]-5:
  39. tscore.clear()
  40. tfood.clear()
  41. gameover()
  42. tscore.clear()
  43. tfood.clear()
  44. gameover()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement