daily pastebin goal
69%
SHARE
TWEET

Untitled

a guest Mar 26th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int LrectY =350;
  2. int RrectY =350;
  3. float ellX=width/2;
  4. float ellY=height/2;
  5. boolean moveRight = true;
  6. boolean moveDown = true;
  7. float  speedSide =3;
  8. float speedVertical =4;
  9. int countR =0;
  10. int countL =0;
  11. PFont font;
  12. void setup (){
  13.   size(700,700);
  14.   background(0);
  15.   font = loadFont("Arial-BoldMT-30.vlw");
  16. }
  17. void draw (){
  18.    background(0);
  19.    textFont (font);
  20.   fill(250,0,0);
  21.   ellipse(ellX,ellY,50,50);
  22.   text("Pong",300,40);
  23.   fill(0,255,0);
  24.   rect(20,LrectY,30,100);
  25.   text(countL,200,50);
  26.   fill(0,0,255);
  27.   rect(630,RrectY,30,100);
  28.   text(countR,500,50);
  29.   if(keyPressed == true && key  =='w'){
  30.     LrectY= LrectY - 6;
  31.   }
  32.    if(keyPressed == true && key  =='s'){
  33.     LrectY= LrectY + 6;
  34.   }
  35.    if(keyPressed == true && key  =='i'){
  36.     RrectY= RrectY - 6;
  37.   }
  38.    if(keyPressed == true && key  =='k'){
  39.     RrectY= RrectY + 6;
  40.   }
  41.  
  42.  if(moveRight == true){
  43.    ellX= ellX + speedSide;
  44.  }else{
  45.    ellX =ellX - speedSide;
  46.  }
  47.  if(moveDown == true){
  48.    ellY= ellY + speedVertical;
  49.  }else{
  50.    ellY =ellY - speedVertical;
  51.  }
  52.  if(ellY <=10){
  53.    moveDown = true;
  54.  speedSide = random(3, 6);
  55.  }
  56.  if(ellY>=690){
  57.    moveDown = false;
  58.    speedSide = random(3, 6);
  59.  }
  60.  
  61. if(ellX >=690){
  62.   countL++;
  63.   ellX=width/2;
  64.   ellY=height/2;
  65.   speedSide = random(3, 6);
  66. }
  67. if(ellX<=10){
  68.   countR++;
  69.   ellX = width /2;
  70.   ellY=height/2;
  71.   speedSide = random(3, 6);
  72. }
  73. if(ellX>+615 && ellY>RrectY && ellY<(RrectY + 100)){
  74.   moveRight = false;
  75. }
  76. if (ellX<=75 && ellY> LrectY && ellY< (LrectY +100)){
  77.   moveRight = true;
  78. }
  79. }
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