SHARE
TWEET

Untitled

a guest Nov 28th, 2016 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Bob{float x,y;Bob(float x,float y){this.x=x;this.y=y;}void display(){fill(y-x,x,y);ellipse(x,y,24,24);}void move(){if(x<=788){x+=5;}}
  2.  
  3. void finish(String name1){textSize(69);fill(random(1,255),random(1,255),random(1,255));text("YAY! "+name1+" wins!",100,400);
  4.  
  5. textSize(30);}void re(){fill(random(1,255),random(1,255),random(1,255));rect(350,550,100,100);fill(204,200,255);
  6.  
  7. textSize(20);text("Rematch?",356,603);}}Bob bob1;Bob bob2;void setup(){size(800,800);bob1=new Bob(51,300);bob2=new Bob(51,500);}
  8.  
  9. void draw(){if(bob1.x<788&&bob2.x<788){background(0);fill(255,0,0);rect(63,0,24,800);bob1.display();
  10.  
  11. bob2.display();}else if(bob1.x>=788&&bob2.x<788){bob1.finish("Player 1");bob1.re();}
  12.  
  13. else if(bob2.x>=788){bob2.finish("Player 2");bob1.re();}else{bob2.re();}}
  14.  
  15. void keyPressed(){if(key=='d'){bob1.move();}if(key=='a'){bob1.move();}if(keyCode==RIGHT){bob2.move();}if(keyCode==LEFT){bob2.move();}}
  16.  
  17. void mouseClicked(){if(mouseX>=350&&mouseX<=450&&mouseY>=550&&mouseY<=650){bob1.x=51;bob2.x=51;}}
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