Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def setup():
- global manx,many,manh,manw,manfill,pennyx,pennyy,pennysize,pennyspeed,pennyfill,arcx,arcy,arcsize,arccolor
- global wallx,wally1,wally2,floorx1,floorx2,floory,arcdropx,arcdropy1,arcdropy2
- global throw,pause,menu
- global counter,backgroundcolor,textcolor,textsize,randomnumber,scores
- global restartx,restarty,restarth,restartw,pausex,pausey,pauseh,pausew,clickx,clicky,clickh,clickw,scorex,scorey,scorew,scoreh
- #---objects---
- manx = 0
- many = 350
- manh = 100
- manw = 50
- manfill = 255
- pennyx = 50
- pennyy = 400
- pennysize = 10
- pennyspeed = 2
- pennyfill = color(139,69,19)
- arcx = 0
- arcy = 400
- arccolor = 0
- #---boundries---
- wallx = 650
- wally1 = 450
- wally2 = 0
- floorx1 = 0
- floorx2 = 675
- floory = 450
- arcdropx = 0
- arcdropy1 = floory
- arcdropy2 = arcy
- restartx = 500
- restarty = 20
- restarth = 50
- restartw = 100
- pausex = restartx
- pausey = restarty + restarth
- pausew = restartw
- pauseh = restarth
- clickx = 270
- clicky = 450
- clickh = restarth
- clickw = restartw
- scorex = restartx
- scorey = restarty + (restarth*2)
- scoreh = restarth
- scorew = restartw
- #---booleans---
- throw = False
- pause = False
- menu = "game"
- #---other---
- counter = 0
- backgroundcolor = 180
- textcolor = color(255,0,0)
- textsize = 40
- randomnumber = 0
- scorefile = open("highscores.txt")
- words = scorefile.readlines()
- #---code---
- size(675,500)
- randomnumber = random.randint(1,10)*20
- arcsize = randomnumber
- def draw():
- global wallx,wally1,wally2,floorx1,floorx2,floory,arcdropx,arcdropy1,arcdropy2
- global manx,many,manh,manw,manfill,pennyx,pennyy,pennysize,pennyspeed,pennyfill,arcx,arcy,arcsize,arccolor
- global throw,pause,randomnumber
- global counter,backgroundcolor,textcolor,textsize,randomnumber,scores
- global restartx,restarty,restarth,restartw,pausex,pausey,pauseh,pausew,clickx,clicky,clickh,clickw,scorex,scorey,scorew,scoreh
- if menu == "game":
- background(backgroundcolor)
- textSize(30)
- fill(textcolor)
- text(("Clicks: " + str(counter)),0,30)
- arcx = manx + (arcsize / 2) + manw
- arcdropx = arcx + (arcsize / 2)
- fill(50,156,69)
- rect(restartx,restarty,restartw,restarth)
- fill(69,11,200)
- rect(pausex,pausey,pausew,pauseh)
- fill(255,99,71)
- rect(clickx,clicky,clickw,clickh)
- fill(0,191,255)
- rect(scorex,scorey,scorew,scoreh)
- fill(255)
- text("Restart",499,56)
- text("Pause",508,56+pauseh)
- text("Throw",273,485)
- text("Scores",503,56+(pauseh*2))
- line(arcdropx,arcdropy1,arcdropx,arcdropy2)
- line(floorx1,floory,floorx2,floory)
- line(wallx,wally1,wallx,wally2)
- fill(manfill)
- rect(manx,many,manw,manh)
- fill(pennyfill)
- ellipse(pennyx,pennyy,pennysize,pennysize)
- noFill()
- stroke(arccolor)
- arc(arcx,arcy,arcsize,arcsize,PI,TWO_PI)
- if throw:
- if pennyx < manx + manw + arcsize:
- pennyx = pennyx + pennyspeed
- pennyy = -1 * sqrt((arcsize / 2)**2 - (pennyx - arcx)**2) + arcy
- else:
- pennyx = manx + manw + arcsize
- pennyy = pennyy + pennyspeed + 1
- if pennyy >= floory:
- manx = manx + randomnumber
- pennyx = manx + manw
- pennyy = many + manw
- randomnumber = random.randint(1,10)*20
- arcsize = randomnumber
- throw = False
- if pennyx >= wallx:
- throw = False
- gameover = True
- pennyx = wallx
- pennyy = pennyy + pennyspeed + 1
- fill(textcolor)
- textSize(textsize)
- text(("You Win! You finished in "+ str(counter) + " clicks"),15,300)
- if pennyy >= floory:
- pennyy = floory
- arcy = 10000
- if menu == "scores":
- scorelist = get_scores(scorelist)
- background(70,130,180)
- fill(0,191,255)
- rect(scorex,scorey,scorew,scoreh)
- fill(255)
- text("Return",503,56+(pauseh*2))
- for i in range(5):
- text(str(i+1) + ".",100,(i*100)+300)
- text(scorelist[i][0],200,(i*100)+300)
- text("(" + scorelist[i][1] + ")",400,(i*100)+300)
- def mouseClicked():
- global pennyx,throw,counter,pause,menu
- global restartx,restarty,restarth,restartw
- global scorex,scorey,scorew,scoreh
- if menu == "game":
- if pausex < mouseX < pausex + pausew and pausey < mouseY < pausey + pauseh:
- if pause:
- pause = False
- else:
- pause = True
- if pennyx < 650 and pause != True and clickx < mouseX < clickx + clickw and clicky < mouseY < clicky + clickh:
- if throw != True:
- counter = counter + 1
- throw = True
- if scorex < mouseX < scorex + scorew and scorey < mouseY < scorey + scoreh:
- menu = "scores"
- if restartx < mouseX < restartx + restartw and restarty < mouseY < restarty + restarth:
- setup()
- def plzsort(what):
- for i in range(len(what) - 1):
- for j in range(len(what) - 1 - i):
- if what[j] > what[j+1]:
- what[j], what[j+1] = what[j+1],what[j]
- return what
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement