Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Tuto 7 : Score et bouton
- BOSSUET Léo
- 14/11/2017
- */
- int x=12;
- int y=388;
- int vx=5;
- int dx=1;
- int vy=5;
- int dy=1;
- int xR=0;
- int yR=390;
- int score=0;
- int xB=820;
- int yB=280;
- int L=160;
- int H=70;
- int atemps=second();
- int ascore=0;
- boolean perdu=false;
- void settings()
- {
- size(1000,400);
- }
- void setup()
- {
- }
- void draw()
- {
- background(#08E0FA);
- stroke(0,0,0);
- strokeWeight(1);
- fill(#3AD80F);
- rect(800,0,200,400);
- textSize(35);
- fill(#050D9B);
- text("Snapi Pong",808,50);
- textSize(25);
- fill(#C90C2F);
- text("SCORE :",808,150);
- text(score,920,150);
- textSize(24);
- fill(#E8850C);
- text("Vx :",808,210);
- text(vx,860,210);
- textSize(24);
- fill(#E8850C);
- text("Vy :",808,240);
- text(vy,860,240);
- stroke(0,0,0);
- strokeWeight(5);
- fill(#F50C0C);
- rect(xB,yB,L,H);
- textSize(32);
- fill(#FC8B00);
- text("REJOUER",835,327);
- if(perdu==false)
- {
- stroke(0,0,0);
- strokeWeight(2);
- fill(#CE1515);
- ellipse(x,y,20,20);
- x=x+dx*vx;
- y=y+vy*dy;
- score=millis()/100-ascore;
- }
- stroke(0,0,0);
- strokeWeight(1);
- fill(#6BFA08);
- rect(xR,yR,10,80);
- yR=mouseY;
- if (second()-atemps==10)
- {
- vx=vx+2;
- vy=vy+2;
- atemps=second();
- }
- if (mouseY>320)
- {
- yR=320;
- }
- if(x>=790)
- {
- dx=-1;
- }
- if(y>=390)
- {
- dy=-1;
- }
- y=y+vy*dy;
- if(y<=10)
- {
- dy=1;
- }
- if(x<20&&(y<mouseY+80)&&(y>mouseY))
- {
- dx=1;
- }
- else if(x<0)
- {
- perdu=true;
- textSize(40);
- fill(#C60000);
- text("Vous avez perdu!!!",220,200);
- }
- }
- void mouseClicked()
- {
- if((mouseX>xB)&&(mouseX<xB+L)&&(mouseY>yB)&&(mouseY<yB+H)&&(perdu==true))
- {
- println("clic");
- perdu=false;
- vx=5;
- vy=5;
- x=12;
- y=388;
- dx=1;
- dy=1;
- score=0;
- ascore=millis()/100;
- atemps=millis()/100;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement