Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float rectX;
- float rectY;
- float rectR;
- float sizew;
- float sizeh;
- float size2w;
- float size2h;
- float rect2X;
- float rect2Y;
- float rect2R ;
- float x = 200;
- float y = 350;
- float ballR = 25;
- int lives = 3;
- float gettingrekt = 0;
- float gettingrekt2 = 0;
- float Fspeed;
- void setup() {
- size(600, 400);
- rectY = 0;
- rectX = random(0, 600);
- rect2Y = 0;
- rect2X = random(0, 600);
- sizew = random(50, 70);
- sizeh = sizew;
- size2w = random(50, 80);
- size2h = size2w;
- rectR = sizew / 2;
- rect2R = size2w / 2;
- Fspeed = rect2Y += random(1, 10);
- rectY += random(1,10);
- }
- void draw() {
- background(0, 0, 0);
- String s = "Lives:" +lives;
- textSize(32);
- fill(50);
- text(s, 10, 25);
- if ( dist(rectX, rectY, x, y)<= ballR + rectR) {
- if (gettingrekt == 0) {
- lives -= 1;
- gettingrekt = 1;
- }
- background(255, 0, 0);
- } else {
- gettingrekt = 0;
- }
- if ( dist(rect2X, rect2Y, x, y)<= ballR + rectR) {
- if (gettingrekt2 == 0) {
- lives -= 1;
- gettingrekt2 = 1;
- }
- background(255, 0, 0);
- } else {
- gettingrekt2 = 0;
- }
- if (lives <= 0) {
- background(255, 5, 5);
- String t = "GameOver";
- textSize(64);
- fill(50);
- text(t, 150, 200);
- String r = "Press Shift to Continue";
- textSize(32);
- fill(50);
- text(r, 125, 250);
- rectY = 0;
- rect2Y = 0;
- }
- noStroke();
- Fspeed = rectY += random(2,8);
- fill(255, 0, 0);
- ellipse( rectX, rectY, size2h, size2w);
- if (rectY > height) {
- Fspeed = rectY += random(1,8);
- rectX = random(0, 600);
- size2w= random(50, 75);
- size2h = size2w;
- rectY = 0;
- }
- rect2Y += random(1, 10);
- fill(255, 0, 0);
- ellipse( rect2X, rect2Y, sizeh, sizew);
- if (rect2Y > height) {
- rect2Y = 0;
- rect2X = x;
- sizew= random(50, 75);
- sizeh = sizew;
- rect2Y += random(1, 10);
- }
- fill(255);
- ellipse(x, y, 50, 50);
- if (x > width)
- x = 590;
- if (x < 0 )
- x = 15;
- {
- }
- }
- void keyPressed() {
- if (key == CODED) {
- if (keyCode == LEFT)
- x -=25;
- if (keyCode == RIGHT)
- x+= 25;
- if (keyCode == SHIFT) {
- rect2Y += random(1,10);
- rectY += random(1,10);
- background(0, 0, 0);
- lives = 3;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement