p14082003

laser(classes);

Apr 15th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. class laser {
  2.   float x=random(0, width);
  3.   float y=random(-500, -100);
  4.   float ys=random(1.5, 4);
  5.  
  6.   void fall() {
  7.     y=y+ys;
  8.   }    
  9.  
  10.   void show() {
  11.     strokeWeight(width/128);
  12.     stroke(255);
  13.     line(x, y, x, y+10);
  14.     if (y>height) {
  15.       score=score+10;
  16.       y=random(-200, -100);
  17.     }
  18.   }
  19.   void touch() {
  20.     if (dist(mouseX, mouseY, l[i].x, l[i].y)<30) {
  21.       for (i=0; i<l.length; i++) {
  22.         background(0);
  23.         l[i].ys=0;
  24.       }
  25.       fill(255);
  26.       textAlign(CENTER, CENTER);
  27.       text("GAME OVER", width/2, height/2);
  28.       for (i=0; i<l.length; i++) {
  29.         l[i].ys=random(1, 1.5);
  30.         l[i].y=random(-500, -100);
  31.         l[i].x=random(0, width);
  32.       }
  33.       score=0;
  34.       lost=true;
  35.     }
  36.   }
  37. }
Add Comment
Please, Sign In to add comment