Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def setup():
- global scoreInt, rectX, rectY, rectPressed,rectSize
- size(500, 500)
- scoreInt = 0
- rectX = width / 2 - 50
- rectY = width / 2 - 50
- rectSize = 100
- rectPressed = False
- def draw():
- global scoreInt, rectX, rectY, rectPressed, rectSize
- background(0,0,0)
- textSize(20)
- text ("Your score: " + str(scoreInt), 50, 50)
- rect(rectX, rectY, rectSize, rectSize)
- if rectPressed == True:
- scoreInt += 20
- rectSize = random(50, 200)
- rectX = random(width - 100)
- rectY = random(height - 100)
- rectPressed = False
- def mousePressed():
- global scoreInt, rectX, rectY, rectPressed
- if mouseX >= rectX and mouseY >= rectY and mouseX <= rectX +rectSize and mouseY <= rectY +rectSize and mouseButton == LEFT:
- rectPressed = True
- else:
- scoreInt += 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement