Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- time = 0
- inc = False
- wait = False
- dec = False
- #Vaste setup
- #Te druk, moet anders
- def setup():
- size(500,500)
- global rectX, rectY, rectSize, w_key, a_key, s_key, d_key, space_key, w_pressed, a_pressed, s_pressed, d_pressed, inc, rectR, rectG, rectB, wait, dec, time
- rectSize = 100
- rectX = width / 2 - 50
- rectY = height / 2 - 50
- w_key = 87
- a_key = 65
- s_key = 83
- d_key = 68
- space_key = 32
- w_pressed = False
- a_pressed = False
- s_pressed = False
- d_pressed = False
- rectR = 0
- rectG = 0
- rectB = 0
- #Basis controlls
- def draw():
- background(255,0,0)
- rectColor()
- global rectX, rectY, rectSize, w_key, a_key, s_key, d_key, space_key, w_pressed, a_pressed, s_pressed, d_pressed, inc, dec, rectR, rectG, rectB, wait, dec, time
- fill (color(rectR, rectG, rectB))
- rect (rectX, rectY, rectSize, rectSize)
- if w_pressed == True:
- rectY -= 3
- print time
- if s_pressed == True:
- rectY += 3
- if a_pressed == True:
- rectX -= 3
- if d_pressed == True:
- rectX += 3
- if inc == True:
- rectSize += 2
- if rectSize > 200 and inc == True:
- inc = False
- wait = True
- time = millis()
- if wait == True and millis() > time + 6000:
- wait = False
- dec = True
- if rectSize >= 100 and dec == True:
- rectSize += -2
- if rectSize == 100 and dec == True:
- dec = False
- wait = False
- #Verander de kleur van de rectangle aan de hand van zijn positie en grootte
- def rectColor():
- global rectX, rectY, rectR, rectG, rectB, wait
- #linksboven
- if rectX <= 0 and rectY <= 0 and wait == False:
- rectR = 0
- rectG = 0
- rectB = 255
- elif rectX <= 0 and rectY <= 0 and wait == True:
- rectR = 255
- rectG = 0
- rectB = 255
- #rechtsboven
- if rectX >= 400 and rectY <= 0 and wait == False:
- rectR = 255
- rectG = 255
- rectB = 0
- elif rectX >= 300 and rectY <= 0 and wait == True:
- rectR = 255
- rectG = 255
- rectB = 255
- #linksonder
- if rectX <= 0 and rectY >= 400 and wait == False:
- rectR = 255
- rectG = 128
- rectB = 0
- elif rectX <= 0 and rectY >= 300 and wait == True:
- rectR = 255
- rectG = 0
- rectB = 0
- #rechtsonder
- if rectX >= 400 and rectY >= 400 and wait == False:
- rectR = 0
- rectG = 255
- rectB = 0
- elif rectX >= 300 and rectY >= 300 and wait == True:
- rectR = 0
- rectG = 255
- rectB = 255
- def keyPressed():
- global w_key, a_key, s_key, d_key, space_key, w_pressed, a_pressed, s_pressed, d_pressed, inc, wait, dec
- if keyCode == w_key:
- w_pressed = True
- if keyCode == s_key:
- s_pressed = True
- if keyCode == a_key:
- a_pressed = True
- if keyCode == d_key:
- d_pressed = True
- if keyCode == space_key and wait == False and dec == False:
- inc = True
- def keyReleased():
- global w_key, a_key, s_key, d_key, space_key, w_pressed, a_pressed, s_pressed, d_pressed, inc
- if keyCode == w_key:
- w_pressed = False
- if keyCode == s_key:
- s_pressed = False
- if keyCode == a_key:
- a_pressed = False
- if keyCode == d_key:
- d_pressed = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement