Advertisement
Fenny_Theo

final version2

Apr 26th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. def timing():
  2. global g_direction
  3. global timeBegin
  4. global timeNow
  5. global moveTime
  6. if g_direction!=None:
  7. timeNow = time.time()
  8. moveTime=timeNow-timeBegin
  9. screen.ontimer(timing,500)
  10.  
  11.  
  12.  
  13.  
  14.  
  15. def title():#including contact&timer
  16. global contacting
  17. global caught
  18. global moveTime
  19. #turtle.title("Snake: Contacted: %d Time: %d"%(contact(),timing())
  20. turtle.title("Snake: Contact: %d Time: %d" %(contacting,moveTime))
  21. if caught==True:
  22. return
  23. if len(head.stampItems)==50:
  24. return
  25.  
  26. screen.ontimer(title,500)#speed=contact
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33. def Game(m,n):
  34. global caught
  35. global timeBegin
  36. text.clear()
  37. setFood()
  38. screenControl()
  39. timeBegin=time.time()
  40. snakeMove()
  41. monsterMove()
  42. contact()
  43. timing()
  44. title()
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52. if __name__ == "__main__":
  53. setWrite()
  54. setSnake()
  55. setMonster()
  56. screen.onclick(Game)
  57. screen.listen()
  58. screen.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement