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,gameover
- global counter,backgroundcolor,textcolor,textsize,randomnumber
- #---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 = arcx
- restartx = 600
- restarty = 100
- restarth = 50
- restartw = 100
- #---booleans---
- throw = False
- gameover = False
- #---other---
- counter = 0
- backgroundcolor = 180
- textcolor = color(255,0,0)
- textsize = 40
- randomnumber = 0
- #---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,gameover,randomnumber
- global counter,backgroundcolor,textcolor,textsize,randomnumber, counter
- background(backgroundcolor)
- textSize(30)
- fill(textcolor)
- text(("Clicks: " + str(counter)),0,30)
- arcx = manx + (arcsize / 2) + manw
- arcdropx = arcx + (arcsize / 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)
- text("click anywhere to restart game",30,100)
- if pennyy >= floory:
- pennyy = floory
- manx = wallx - manw
- arcy = 10000
- def mouseClicked():
- global pennyx,throw,counter,gameover
- if pennyx < 650:
- throw = True
- counter = counter + 1
- if gameover:
- setup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement