davk

dumbgame

Jan 29th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void setup()
  2. {
  3.     size(600,600);
  4.     frameRate(24);
  5. }
  6.  
  7. var y = 550;
  8. var x = 300;
  9. var x1 = 150;
  10. var cible_direction = 0;
  11. var win = 0;
  12. var pause = 0;
  13. var start = 0;
  14.  
  15. draw = function()
  16. {
  17.     if(keyPressed == true)
  18.     {
  19.         if(key == CODED)
  20.         {
  21.             if(keyCode == LEFT && x>20 && y>27)
  22.             {
  23.                 x = x-4;
  24.             }
  25.             else if(keyCode == RIGHT && x<580 && y > 27)
  26.             {
  27.                 x = x+4;
  28.             }
  29.         }
  30.  
  31.     }
  32.     background(#FFFFEE);
  33.     fill(255, 0, 0),
  34.     rect(x1,-1,300,50);
  35.     fill(55, 15, 255);
  36.     rect(500, 500, 100, 100);
  37.     fill(15, 255, 15);
  38.     ellipse(x,y,50,50);
  39.     if(cible_direction == 0)
  40.     {
  41.         x1 = x1-4;
  42.         if(x1<0) cible_direction = 1;
  43.     }
  44.     else
  45.     {
  46.         x1 = x1+4;
  47.         if(x1>300) cible_direction = 0;
  48.     }
  49.     if(y>27)
  50.     {
  51.         if(y<75)
  52.         {
  53.             if(x<(x1+299) && x>(x1+250))
  54.                 x=x-4;
  55.             else if(x>(x1+1) && x<(x1+50))
  56.                 x=x+4;
  57.         }
  58.         y = y-4;
  59.     }
  60.     else
  61.     {
  62.         if(x<(x1+300) && x>x1 && win == 0)
  63.         {
  64.             alert("try again!");
  65.             win = 1;
  66.         }
  67.         y = 550;
  68.         win = 0;
  69.     }
  70.     if(pause == 1) y=550;
  71.     if(mousePressed)
  72.     {
  73.     if(mouseX < (x+25) && mouseX > (x-25) && mouseY < (y+25) && mouseY > (y-25) && pause == 0)
  74.     {
  75.         pause = 1;
  76.         start = 0;
  77.     }
  78.     if(mouseX < 600 && mouseX > 500 && mouseY < 600 && mouseY > 500 && start == 0)
  79.     {
  80.         pause = 0;
  81.         start = 1;
  82.     }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment