Advertisement
dmesticg

PennyPitch V4

Feb 14th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. import random
  2. def setup():
  3. global manx,many,manh,manw,manfill,pennyx,pennyy,pennysize,pennyspeed,pennyfill,arcx,arcy,arcsize,arccolor
  4. global wallx,wally1,wally2,floorx1,floorx2,floory,arcdropx,arcdropy1,arcdropy2
  5. global throw,gameover
  6. global counter,backgroundcolor,textcolor,textsize,randomnumber
  7. #---objects---
  8. manx = 0
  9. many = 350
  10. manh = 100
  11. manw = 50
  12. manfill = 255
  13. pennyx = 50
  14. pennyy = 400
  15. pennysize = 10
  16. pennyspeed = 2
  17. pennyfill = color(139,69,19)
  18. arcx = 0
  19. arcy = 400
  20. arccolor = 0
  21. #---boundries---
  22. wallx = 650
  23. wally1 = 450
  24. wally2 = 0
  25. floorx1 = 0
  26. floorx2 = 675
  27. floory = 450
  28. arcdropx = 0
  29. arcdropy1 = floory
  30. arcdropy2 = arcx
  31. restartx = 600
  32. restarty = 100
  33. restarth = 50
  34. restartw = 100
  35. #---booleans---
  36. throw = False
  37. gameover = False
  38. #---other---
  39. counter = 0
  40. backgroundcolor = 180
  41. textcolor = color(255,0,0)
  42. textsize = 40
  43. randomnumber = 0
  44. #---code---
  45. size(675,500)
  46. randomnumber = random.randint(1,10)*20
  47. arcsize = randomnumber
  48.  
  49.  
  50. def draw():
  51. global wallx,wally1,wally2,floorx1,floorx2,floory,arcdropx,arcdropy1,arcdropy2
  52. global manx,many,manh,manw,manfill,pennyx,pennyy,pennysize,pennyspeed,pennyfill,arcx,arcy,arcsize,arccolor
  53. global throw,gameover,randomnumber
  54. global counter,backgroundcolor,textcolor,textsize,randomnumber, counter
  55. background(backgroundcolor)
  56. textSize(30)
  57. fill(textcolor)
  58. text(("Clicks: " + str(counter)),0,30)
  59. arcx = manx + (arcsize / 2) + manw
  60. arcdropx = arcx + (arcsize / 2)
  61. line(arcdropx,arcdropy1,arcdropx,arcdropy2)
  62. line(floorx1,floory,floorx2,floory)
  63. line(wallx,wally1,wallx,wally2)
  64. fill(manfill)
  65. rect(manx,many,manw,manh)
  66. fill(pennyfill)
  67. ellipse(pennyx,pennyy,pennysize,pennysize)
  68. noFill()
  69. stroke(arccolor)
  70. arc(arcx,arcy,arcsize,arcsize,PI,TWO_PI)
  71. if throw:
  72. if pennyx < manx + manw + arcsize:
  73. pennyx = pennyx + pennyspeed
  74. pennyy = -1 * sqrt((arcsize / 2)**2 - (pennyx - arcx)**2) + arcy
  75. else:
  76. pennyx = manx + manw + arcsize
  77. pennyy = pennyy + pennyspeed + 1
  78. if pennyy >= floory:
  79. manx = manx + randomnumber
  80. pennyx = manx + manw
  81. pennyy = many + manw
  82. randomnumber = random.randint(1,10)*20
  83. arcsize = randomnumber
  84. throw = False
  85. if pennyx >= wallx:
  86. throw = False
  87. gameover = True
  88. pennyx = wallx
  89. pennyy = pennyy + pennyspeed + 1
  90. fill(textcolor)
  91. textSize(textsize)
  92. text(("You Win! You finished in "+ str(counter) + " clicks"),15,300)
  93. text("click anywhere to restart game",30,100)
  94. if pennyy >= floory:
  95. pennyy = floory
  96. manx = wallx - manw
  97. arcy = 10000
  98.  
  99. def mouseClicked():
  100. global pennyx,throw,counter,gameover
  101. if pennyx < 650:
  102. throw = True
  103. counter = counter + 1
  104. if gameover:
  105. setup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement