Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup()
- {
- size(600,600);
- frameRate(24);
- }
- var y = 550;
- var x = 300;
- var x1 = 150;
- var cible_direction = 0;
- var win = 0;
- var pause = 0;
- var start = 0;
- draw = function()
- {
- if(keyPressed == true)
- {
- if(key == CODED)
- {
- if(keyCode == LEFT && x>20 && y>27)
- {
- x = x-4;
- }
- else if(keyCode == RIGHT && x<580 && y > 27)
- {
- x = x+4;
- }
- }
- }
- background(#FFFFEE);
- fill(255, 0, 0),
- rect(x1,-1,300,50);
- fill(55, 15, 255);
- rect(500, 500, 100, 100);
- fill(15, 255, 15);
- ellipse(x,y,50,50);
- if(cible_direction == 0)
- {
- x1 = x1-4;
- if(x1<0) cible_direction = 1;
- }
- else
- {
- x1 = x1+4;
- if(x1>300) cible_direction = 0;
- }
- if(y>27)
- {
- if(y<75)
- {
- if(x<(x1+299) && x>(x1+250))
- x=x-4;
- else if(x>(x1+1) && x<(x1+50))
- x=x+4;
- }
- y = y-4;
- }
- else
- {
- if(x<(x1+300) && x>x1 && win == 0)
- {
- alert("try again!");
- win = 1;
- }
- y = 550;
- win = 0;
- }
- if(pause == 1) y=550;
- if(mousePressed)
- {
- if(mouseX < (x+25) && mouseX > (x-25) && mouseY < (y+25) && mouseY > (y-25) && pause == 0)
- {
- pause = 1;
- start = 0;
- }
- if(mouseX < 600 && mouseX > 500 && mouseY < 600 && mouseY > 500 && start == 0)
- {
- pause = 0;
- start = 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment