Facebook
From gerdajansen, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 204
  1. int score = 0;
  2. int positieX = 250;
  3. int positieY = 250;
  4. float cirkelX = 100;
  5. float cirkelY = 100;
  6. int teller = 0;
  7. int i = 0;
  8. int cirkelgrootte = 20;
  9.  
  10.  
  11.  
  12.  
  13.  
  14. void setup(){
  15.  size(500,500);
  16.  frameRate(60);
  17.  
  18. }
  19.  
  20. void draw(){
  21.  background(0,0,0);
  22.  textSize(20);
  23.  text("Score: " +score,400,20);
  24.   ellipse(cirkelX,cirkelY,8,8);
  25.   rect(positieX,positieY,20,cirkelgrootte);
  26.  
  27.  
  28. if(positieX > 480){
  29.   positieX = 480;
  30. }
  31.  
  32.   if(positieX < 0){
  33.   positieX = 0;
  34.  
  35.   if(positieY < 0){
  36.   positieY = 0;
  37.   }
  38.  
  39. }
  40.  
  41.  
  42.  
  43.   if(dist(positieX,positieY,cirkelX,cirkelY) < 15){
  44.    score = score + 1;
  45.    cirkelX = random(0,480);
  46.    cirkelY = random(0,480);
  47.   }
  48.  
  49.  
  50.  
  51.   if(keyPressed == true){
  52.    if(keyCode == RIGHT){
  53.      positieX = positieX + 3;
  54.   }
  55.   if(keyCode == LEFT){
  56.     positieX = positieX - 3;
  57.    
  58.   }
  59.  
  60.       if(keyCode == UP){
  61.     positieY = positieY - 3;
  62.    
  63.       }
  64.      
  65.       if(keyCode == DOWN){
  66.         positieY = positieY + 3;
  67.        
  68.         if(score > 1){
  69.           cirkelgrootte = 25;
  70.        
  71.        
  72.         }
  73.        
  74.      
  75.  
  76.  
  77.  
  78.   }
  79.  
  80.    
  81.    
  82. }
  83. }
  84.    
  85.    
  86.