Advertisement
Guest User

before.py

a guest
Nov 5th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.08 KB | None | 0 0
  1. #imports the turtle module
  2. import turtle
  3. #sets up the display, turtle is the module Screen is the object and () invokes it
  4. wn = turtle.Screen()
  5. #calls wn which is my shorthand for window, and makes the background black
  6. wn.bgcolor("black")
  7.  
  8. #this whole block creates the ten turtles, again turtle is the module and Turtle is the object
  9. artist1 = turtle.Turtle()
  10. artist2 = turtle.Turtle()
  11. artist3 = turtle.Turtle()
  12. artist4 = turtle.Turtle()
  13. artist5 = turtle.Turtle()
  14. artist6 = turtle.Turtle()
  15. artist7 = turtle.Turtle()
  16. artist8 = turtle.Turtle()
  17. artist9 = turtle.Turtle()
  18. artist10 = turtle.Turtle()
  19.  
  20. #modifies the turtles so that they don't all print the same color
  21. artist1.color("red")
  22. artist2.color("blue")
  23. artist3.color("purple")
  24. artist4.color("brown")
  25. artist5.color("Gold")
  26. artist6.color("DarkKhaki")
  27. artist7.color("OrangeRed")
  28. artist8.color("DarkSlateGray")
  29. artist9.color("MediumSpringGreen")
  30. artist10.color("ForestGreen")
  31.  
  32. #I put this here so that you can't se the turtles, but instead the lines they draw
  33. artist1.shape("blank")
  34. artist2.shape("blank")
  35. artist3.shape("blank")
  36. artist4.shape("blank")
  37. artist5.shape("blank")
  38. artist6.shape("blank")
  39. artist7.shape("blank")
  40. artist8.shape("blank")
  41. artist9.shape("blank")
  42. artist10.shape("blank")
  43.  
  44. #makes them all move as fast as possible (speed is set at 1 to 9 with 0 being faster than 9, being last on the number bar)
  45. artist1.speed(0)
  46. artist2.speed(0)
  47. artist3.speed(0)
  48. artist4.speed(0)
  49. artist5.speed(0)
  50. artist6.speed(0)
  51. artist7.speed(0)
  52. artist8.speed(0)
  53. artist9.speed(0)
  54. artist10.speed(0)
  55.  
  56. #with the penup command used, the artists will be able to walk around, without leaving a trail this way I can get them into position
  57. artist1.penup()
  58. artist2.penup()
  59. artist3.penup()
  60. artist4.penup()
  61. artist5.penup()
  62. artist6.penup()
  63. artist7.penup()
  64. artist8.penup()
  65. artist9.penup()
  66. artist10.penup()
  67.  
  68. #rather unimportant, at first there were four artists, rather than ten, so I turned them all to the cardinal directions, 2 was already facing right, as they spawn that way, so I didn't change it
  69. artist1.left(90)
  70. artist3.right(90)
  71. artist4.right(180)
  72. #brings in the random number generator, a module that generates random numbers, imagine that
  73. import random
  74.  
  75. #sets values that I later used for rotation, did the same thing as the .left and right modifiers on artists 1-4, this way it was more spontaneous
  76. #I don't know why I used 1 through 361 rather than 0 through 360, I guess I'm just stupid like that
  77. a = random.randrange(1,361)
  78. b = random.randrange(1,361)
  79. c = random.randrange(1,361)
  80. d = random.randrange(1,361)
  81. e = random.randrange(1,361)
  82. f = random.randrange(1,361)
  83. #this passes the generated number on to the turtles so they can rotate that way
  84. artist5.right(a)
  85. artist6.right(b)
  86. artist7.right(c)
  87. artist8.right(d)
  88. artist9.right(e)
  89. artist10.right(f)
  90.  
  91. #another remnant of my dumbassery, I used words meaning rotate for the first four, which was all I had in the original version of this script, then when I added the other six I scrapped that
  92. #these variables tell them how far to walk from the center, makes them show up in a different position each time
  93. turn = random.randrange(45,180)
  94. twist = random.randrange(45,180)
  95. rotate = random.randrange(45,180)
  96. spin = random.randrange(45,180)
  97. t1 = random.randrange(45,180)
  98. t2 = random.randrange(45,180)
  99. t3 = random.randrange(45,180)
  100. t4 = random.randrange(45,180)
  101. t5 = random.randrange(45,180)
  102. t6 = random.randrange(45,180)
  103.  
  104. #I did the same thing here, the name of the variable isn't important, the damn thing works
  105. move = random.randrange(40,60)
  106. walk = random.randrange(40,60)
  107. shuffle = random.randrange(40,60)
  108. scuttle = random.randrange(40,60)
  109. w1 = random.randrange(40,60)
  110. w2 = random.randrange(40,60)
  111. w3 = random.randrange(40,60)
  112. w4 = random.randrange(40,60)
  113. w5 = random.randrange(40,60)
  114. w6 = random.randrange(40,60)
  115.  
  116. #for the longest time I couldn't remember what this even did, I had to look it up
  117. #this runs ten times and each time it replaces x with an artist1 or artist2, corresponding to the run it's on, they walk forward 125 units and start writing when they get there
  118. #come to think of it why didn't I do this with the other variables
  119. #I just went back and checked and I STILL DON'T DO THIS WITH CODE I WRITE NOW, I AM NOT A SMART MAN
  120. for x in[artist1,artist2,artist3,artist4,artist5,artist6,artist7,artist8,artist9,artist10]:
  121.     x.forward(125)
  122.     x.pendown()
  123. #this loop is set to run 120 times, the y is unimportant, it uses the walk and rotate values set earlier, which I wrote again, and again, rather than automating with a loop like this one
  124. #HURR DURR, LET'S TYPE MORE
  125. for y in range(120):
  126.     artist1.forward(move)
  127.     artist2.forward(walk)
  128.     artist3.forward(shuffle)
  129.     artist4.forward(scuttle)
  130.     artist5.forward(w1)
  131.     artist6.forward(w2)
  132.     artist7.forward(w3)
  133.     artist8.forward(w4)
  134.     artist9.forward(w5)
  135.     artist10.forward(w6)
  136.    
  137.     artist1.left(turn)
  138.     artist2.left(twist)
  139.     artist3.left(rotate)
  140.     artist4.left(spin)
  141.     artist5.left(t1)
  142.     artist6.left(t2)
  143.     artist7.left(t3)
  144.     artist8.left(t4)
  145.     artist9.left(t5)
  146.     artist10.left(t6)
  147.  
  148. #makes the screen close when clicked
  149. wn.exitonclick()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement