xxxxxxxxxx
156
///!!!!!!!!!!! WARNING: SCREEN WILL CHANGE TO FLASHY BRIGHT LIGHTS ON ROUND THREE (PASSED SCORE 10) AND MAY CAUSE EPILEPSY SEIZURES!!!!!!!!!!!
// CATCH THE BALL! Joey Avalos.
// In this game, game user will need to succeed to catch the ball anywhere it goes by utilzing the mouse!
/// PASS LEVEL 20!
let ballx =300
let bally = 300
let ballSize = 50
let score = 0
let gamestate = 'LV1';
function setup() {
createCanvas(500, 500);
textAlign(CENTER);
textSize(20);
}
function draw() {
background(0);
if (gamestate == 'LV1'){
lvlOne();
}
if (gamestate == 'LV2'){
lvlTwo();
}
if (gamestate == 'LV3'){
lvlThree();
}
if (gamestate == 'LV4'){
lvlFour();
}
if (gamestate == 'WIN'){
letsWin();
}
text(("score: " + score),width/2,40);
}
function lvlOne(){
background('#0d30bd');
strokeWeight(1);
fill('#2041c7');
textSize(20);
text ('LEVEL ONE', width/2, height -20);
let distToball = dist(ballx,bally,mouseX,mouseY);
stroke(0);
if (distToball < ballSize/2){
ballx = random(width);
bally = random(height);
score = score +1;
}
if(score>=5){
gamestate = 'LV2';
}
//line (ballx,bally,mouseX,mouseY);
ellipse(ballx,bally,ballSize,ballSize);
//end of Level One
}
function lvlTwo(){
background('#deff05');
fill('#cbe61c');
strokeWeight(0);
textSize(20);
text ('LEVEL TWO!', width/2, height -20);
let distToball = dist(ballx,bally,mouseX,mouseY);
stroke(0);
if (distToball < ballSize/2){
ballx = random(width);
bally = random(height);
score = score +1;
}
if(score>=10){
gamestate = 'LV3';
}
//line (ballx,bally,mouseX,mouseY);
ellipse(ballx,bally,ballSize,ballSize);
// end of level two
}
function lvlThree(){
background(random(255));
fill('#800313');
textSize(20);
text ('LEVEL THREE!', width/2, height -20);
let distToball = dist(ballx,bally,mouseX,mouseY);
stroke(0);
if (distToball < ballSize/2){
ballx = random(width);
bally = random(height);
score = score +1;
ballSize= ballSize -5;
}
if(score>=15){
gamestate = 'LV4';
}
//line (ballx,bally,mouseX,mouseY);
ellipse(ballx,bally,ballSize,ballSize);
// end of level three
}
function lvlFour(){
background(random(255));
fill('#540042');
textSize(20);
text ('LEVEL FOUR!', width/2, height -20);
let distToball = dist(ballx,bally,mouseX,mouseY);
stroke(0);
if (distToball < ballSize/2){
ballx = random(width);
bally = random(height);
score = score +1;
ballSize= ballSize -5;
}
if(score>=20){
gamestate = 'WIN';
}
//line (ballx,bally,mouseX,mouseY);
ellipse(ballx,bally,ballSize,ballSize);
// end of level four
}
function letsWin(){
background('#910404');
fill('#bfc421');
strokeWeight(10);
translate(-5,-150);
textSize(20);
text('YOU WIN!! PRESS PLAY BUTTON TO PLAY AGAIN!', width/2, height -20);
}
if(score>=20){
gamestate = 'WIN';
// end of game. YOU WIN!
}