Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. def setup():
  2.     global scoreInt, rectX, rectY, rectPressed,rectSize
  3.     size(500, 500)
  4.     scoreInt = 0
  5.     rectX = width / 2 - 50
  6.     rectY = width / 2 - 50
  7.     rectSize = 100
  8.     rectPressed = False
  9.    
  10. def draw():
  11.     global scoreInt, rectX, rectY, rectPressed, rectSize
  12.     background(0,0,0)
  13.     textSize(20)
  14.     text ("Your score: " + str(scoreInt), 50, 50)
  15.     rect(rectX, rectY, rectSize, rectSize)
  16.     if rectPressed == True:
  17.         scoreInt += 20
  18.         rectSize = random(50, 200)
  19.         rectX = random(width - 100)
  20.         rectY = random(height - 100)
  21.         rectPressed = False
  22.    
  23. def mousePressed():
  24.     global scoreInt, rectX, rectY, rectPressed
  25.     if mouseX >= rectX and mouseY >= rectY and mouseX <= rectX +rectSize and mouseY <= rectY +rectSize and mouseButton == LEFT:
  26.         rectPressed = True
  27.     else:
  28.         scoreInt += 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement