void setup() {
size(500, 500);
rectMode(CENTER);
}
//this block is dedicated to things that I will change
int state=0;
float bouncex = 250, bouncey = 100, bouncevx, bouncevy;
int targetLength=100; //x is the length of the target rectangle
int targetWidth=100;//y is the width of the target rectangle
int positionx=(int)random(0, 500);
int bounceCount=0;
boolean disableBounceCount=false;
int level=0; //0=easy mode, 1=medium, 2=hard
void draw() {
background(0);
if (state==0) {
ellipse(mouseX, mouseY, 10, 10);
text("The Most Intense Game You Will Ever Play. Click to start", 50, 50 );
if (mousePressed) state=1;
}
if (state==1) {
text("Directions: Move mouse to control platform. Click to change directions", 50, 50);
println("");
text("Dont let the ball drop!", 50, 75);
println("");
text("There are three levels. Press 1 for normal. Press 2 for hard. Or press 3 for insane.", 50, 100);
text("For a Greater Challenge, click your mouse rapidly :)",50,125);
chooseLevel();
}
if (state==2) {
fill(255, 100, 100);
text(bounceCount, 15, 20);
fill(255, 0, 0);
rect(mouseX, 400, 50, 10);
fill(255, 100, 0);
ellipse(bouncex, bouncey, 25, 25);
if ( bouncex < 0 && bouncevx < 0 || bouncex > width && bouncevx > 0) bouncevx = -bouncevx;
if ( bouncey < 0 && bouncevy < 0 || bouncey > height && bouncevy > 0) bouncevy = -bouncevy;
if ( (abs(bouncex-mouseX)< 50/2 + 25/2) && (abs(bouncey-400)< 10/2 + 25/2) && bouncevy>0 ) {
bouncevy=-bouncevy;
bouncevx=-bouncevx;
if (!disableBounceCount|| mousePressed) {
bounceCount++;
disableBounceCount=false;
}
if (bouncevx>0) {
bouncevx=bouncevx+(int)random(0, 5);
} else {
bouncevx=bouncevx-(int)random(0, 5);
}
}
bouncex += bouncevx;
bouncey += bouncevy;
}
if (bouncey>500) {
state=100;
bouncex=0;
bouncey=0;
}
if (bounceCount==10) {
disableBounceCount=true;
if (mousePressed) {
disableBounceCount=false;
}
}
if (mousePressed) {
disableBounceCount=false;
bouncevx=15;
bouncevy=15;
}
if (state==100) {
fill(255);
text(bounceCount, 50, 50);
text("Game over! (Hint: Don't look at the ball, look at the platform)", 50, 75);
println(" ");
text("Choose your level: 1,2, or 3 to start again", 50, 100);
chooseLevel();
}
}
void chooseLevel() {
if (keyPressed&&key=='1') {
state=2;
level=0;
bouncevx=5;
bouncevy=5;
}
if (keyPressed&&key=='2') {
state=2;
level=1;
bouncevx=10;
bouncevy=10;
}
if (keyPressed&&key=='3') {
state=2;
level=2;
bouncevx=13;
bouncevy=13;
}
}