Guest User

Untitled

a guest
Sep 24th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. # fallGreetings.py
  2. # Robert Niggebrugge
  3. #
  4. #
  5. # I certify that this is my own work
  6. #
  7. from graphics import *
  8. from time import *
  9.  
  10. win = GraphWin("Greeting", 350, 500, autoflush=False)
  11.  
  12. leaf_1 = Polygon(Point(30,45), Point(32.5,60), Point(35,45))
  13. leaf_2 = Polygon(Point(30,45), Point(30,40), Point(20,42.5))
  14. leaf_3 = Polygon(Point(35,45), Point(45,42.5), Point(35,40))
  15. square_leaf = Rectangle(Point(30,45), Point(35,40))
  16. stem = Line(Point(32.5,40), Point(32.5, 30))
  17.  
  18. square_leaf.setFill("orange")
  19. leaf_1.setFill("orange")
  20. leaf_2.setFill("orange")
  21. leaf_3.setFill("orange")
  22.  
  23.  
  24. leaf_1_C = leaf_1.clone()
  25. leaf_2_C = leaf_2.clone()
  26. leaf_3_C = leaf_3.clone()
  27. square_leaf_C = square_leaf.clone()
  28. stem_C = stem.clone()
  29.  
  30.  
  31. #NOW TRYING TO LOOP BETWEEN FALLING LEAFS AND PUTTING THEM BACK IN POSITION
  32. # NEED TO SET THE LEAF AS A GLOBAL VARIABLE SO THAT IT CAN BE REFERENCED IN EITHER CLASS
  33. # Purpose: to bring up a window for a card that a user can see and click on to go away
  34. def fallGreetings():
  35.  
  36. # this is bringing up the window for the card
  37. #win = GraphWin("Greeting", 350, 500, autoflush=False)
  38.  
  39. # first graphical object
  40. circle = Circle(Point(175,250), 60)
  41. circle.draw(win)
  42. Circle.setFill(circle, "red")
  43.  
  44. # Text graphical object
  45. greet = Text((Point(175,250)), "Happy Fall")
  46. greet.setSize(10)
  47. greet.draw(win)
  48.  
  49. # down part
  50. #leaf_1 = Polygon(Point(30,45), Point(32.5,60), Point(35,45))
  51. leaf_1.draw(win)
  52. # leaf_1_C = leaf_1.clone()
  53.  
  54. # left part
  55. #leaf_2 = Polygon(Point(30,45), Point(30,40), Point(20,42.5))
  56. leaf_2.draw(win)
  57. #leaf_2_C = leaf_2.clone()
  58.  
  59. # right part
  60. #leaf_3 = Polygon(Point(35,45), Point(45,42.5), Point(35,40))
  61. leaf_3.draw(win)
  62. #leaf_3_C = leaf_3.clone()
  63.  
  64. #square in the middle
  65. #square_leaf = Rectangle(Point(30,45), Point(35,40))
  66. square_leaf.draw(win)
  67. #square_leaf_C = square_leaf.clone()
  68.  
  69. #square_leaf.setFill("orange")
  70. #leaf_1.setFill("orange")
  71. #leaf_2.setFill("orange")
  72. #leaf_3.setFill("orange")
  73.  
  74.  
  75. #stem = Line(Point(32.5,40), Point(32.5, 30))
  76. stem.draw(win)
  77. #stem_C = stem.clone()
  78.  
  79. for i in range(150):
  80. leaf_3.move(2, 5)
  81. leaf_2.move(2, 5)
  82. leaf_1.move(2, 5)
  83. square_leaf.move(2, 5)
  84. stem.move(2, 5)
  85. update(30)
  86.  
  87.  
  88.  
  89. def moveclone():
  90. leaf_1_C.draw(win)
  91. leaf_2_C.draw(win)
  92. leaf_3_C.draw(win)
  93. square_leaf_C.draw(win)
  94. stem_C.draw(win)
  95.  
  96.  
  97. #for closing the window
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105. ## PROBLEM: CANT FIND A WAY TO CONTINUOUSLY LOOP BETWEEN greetings and moveclone
  106. ##
  107. def main():
  108. switch == True
  109.  
  110. while switch == True:
  111. fallGreetings()
  112.  
  113. switch = False
  114.  
  115. while switch == False:
  116. moveclone()
  117.  
  118. switch == True
  119.  
  120. win.getMouse()
  121. main()
Add Comment
Please, Sign In to add comment