Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class laser {
- float x=random(0, width);
- float y=random(-500, -100);
- float ys=random(1.5, 4);
- void fall() {
- y=y+ys;
- }
- void show() {
- strokeWeight(width/128);
- stroke(255);
- line(x, y, x, y+10);
- if (y>height) {
- score=score+10;
- y=random(-200, -100);
- }
- }
- void touch() {
- if (dist(mouseX, mouseY, l[i].x, l[i].y)<30) {
- for (i=0; i<l.length; i++) {
- background(0);
- l[i].ys=0;
- }
- fill(255);
- textAlign(CENTER, CENTER);
- text("GAME OVER", width/2, height/2);
- for (i=0; i<l.length; i++) {
- l[i].ys=random(1, 1.5);
- l[i].y=random(-500, -100);
- l[i].x=random(0, width);
- }
- score=0;
- lost=true;
- }
- }
- }
Add Comment
Please, Sign In to add comment