SHARE
TWEET

Untitled

a guest Sep 17th, 2016 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import time
  2. time = 0
  3. inc = False
  4. wait = False
  5. dec = False
  6. #Vaste setup
  7. #Te druk, moet anders
  8. def setup():
  9.     size(500,500)
  10.     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
  11.     rectSize = 100
  12.     rectX = width / 2 - 50
  13.     rectY = height / 2 - 50
  14.     w_key = 87
  15.     a_key = 65
  16.     s_key = 83
  17.     d_key = 68
  18.     space_key = 32
  19.     w_pressed = False
  20.     a_pressed = False
  21.     s_pressed = False
  22.     d_pressed = False  
  23.     rectR = 0
  24.     rectG = 0
  25.     rectB = 0
  26.  
  27.    
  28. #Basis controlls
  29. def draw():
  30.     background(255,0,0)
  31.     rectColor()
  32.     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
  33.     fill (color(rectR, rectG, rectB))    
  34.     rect (rectX, rectY, rectSize, rectSize)
  35.     if w_pressed == True:
  36.         rectY -= 3
  37.     print time
  38.     if s_pressed == True:
  39.         rectY += 3
  40.     if a_pressed == True:
  41.         rectX -= 3
  42.     if d_pressed == True:
  43.         rectX += 3
  44.     if inc == True:
  45.         rectSize += 2
  46.     if rectSize > 200 and inc == True:
  47.         inc = False
  48.         wait = True
  49.         time = millis()
  50.     if wait == True and millis() > time + 6000:
  51.         wait = False
  52.         dec = True
  53.     if rectSize >= 100 and dec == True:
  54.         rectSize += -2  
  55.     if rectSize == 100 and dec == True:
  56.         dec = False
  57.         wait = False
  58.                
  59.    
  60. #Verander de kleur van de rectangle aan de hand van zijn positie en grootte
  61. def rectColor():
  62.    
  63.     global rectX, rectY, rectR, rectG, rectB, wait
  64.  
  65.     #linksboven
  66.     if rectX <= 0 and rectY <= 0 and wait == False:
  67.         rectR = 0
  68.         rectG = 0
  69.         rectB = 255
  70.     elif rectX <= 0 and rectY <= 0 and wait == True:
  71.         rectR = 255
  72.         rectG = 0
  73.         rectB = 255
  74.        
  75.     #rechtsboven
  76.     if rectX >= 400 and rectY <= 0 and wait == False:
  77.         rectR = 255
  78.         rectG = 255
  79.         rectB = 0
  80.     elif rectX >= 300 and rectY <= 0 and wait == True:
  81.         rectR = 255
  82.         rectG = 255
  83.         rectB = 255
  84.    
  85.     #linksonder
  86.     if rectX <= 0 and rectY >= 400 and wait == False:
  87.         rectR = 255
  88.         rectG = 128
  89.         rectB = 0
  90.     elif rectX <= 0 and rectY >= 300 and wait == True:
  91.         rectR = 255
  92.         rectG = 0
  93.         rectB = 0
  94.        
  95.     #rechtsonder
  96.     if rectX >= 400 and rectY >= 400 and wait == False:
  97.         rectR = 0
  98.         rectG = 255
  99.         rectB = 0
  100.     elif rectX >= 300 and rectY >= 300 and wait == True:
  101.         rectR = 0
  102.         rectG = 255
  103.         rectB = 255
  104.  
  105.    
  106. def keyPressed():
  107.     global w_key, a_key, s_key, d_key, space_key, w_pressed, a_pressed, s_pressed, d_pressed, inc, wait, dec
  108.    
  109.  
  110.     if keyCode == w_key:
  111.         w_pressed = True
  112.     if keyCode == s_key:
  113.         s_pressed = True
  114.     if keyCode == a_key:
  115.         a_pressed = True
  116.     if keyCode == d_key:
  117.         d_pressed = True        
  118.     if keyCode == space_key and wait == False and dec == False:
  119.         inc = True
  120.        
  121. def keyReleased():
  122.     global w_key, a_key, s_key, d_key, space_key, w_pressed, a_pressed, s_pressed, d_pressed, inc
  123.     if keyCode == w_key:
  124.         w_pressed = False
  125.     if keyCode == s_key:
  126.         s_pressed = False
  127.     if keyCode == a_key:
  128.         a_pressed = False
  129.     if keyCode == d_key:
  130.         d_pressed = False
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top