Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. from turtle import *
  2.  
  3. v = 100 #скорость черепашки
  4. step = 15 #шаг
  5.  
  6. t = Turtle()
  7. t.color('blue')
  8. t.width(5)
  9. t.shape('circle')
  10. t.pendown()
  11. t.speed(v)
  12.  
  13. def draw(x, y):
  14. t.goto(x, y)
  15.  
  16. def move(x, y):
  17. t.penup()
  18. t.goto(x, y)
  19. t.pendown()
  20.  
  21. def setRed():
  22. t.color('red')
  23.  
  24. def setGreen():
  25. t.color('green')
  26.  
  27. def setBlue():
  28. t.color('blue')
  29.  
  30. def stepUp():
  31. t.goto(t.xcor(), t.ycor() + step)
  32.  
  33. def stepDown():
  34. t.goto(t.xcor(), t.ycor() - step)
  35.  
  36. def stepLeft():
  37. t.goto(t.xcor() - step, t.ycor())
  38.  
  39. def stepRight():
  40. t.goto(t.xcor() + step, t.ycor())
  41.  
  42. def startFill():
  43. t.begin_fill()
  44.  
  45. def endFill():
  46. t.end_fill()
  47.  
  48. t.ondrag(draw)
  49.  
  50. scr = t.getscreen()
  51. scr.onscreenclick(move)
  52. scr.onkey(setRed,'r')
  53. scr.onkey(setGreen,'g')
  54. scr.onkey(setBlue,'b')
  55. scr.onkey(stepUp,'Up')
  56. scr.onkey(stepDown,'Down')
  57. scr.onkey(stepLeft,'Left')
  58. scr.onkey(stepRight,'Right')
  59. scr.onkey(startFill,'f')
  60. scr.onkey(endFill,'e')
  61.  
  62. scr.listen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement