xxxxxxxxxx
100
var screen = 0;
var y=-20;
var x=200;
var speed = 2;
var score= 0;
var hoopImage = false;
var ballImage = false;
function preload() {
hoopImage = loadImage('assets/thehoop.png');
ballImage = loadImage('assets/ball.png');
courtImage = loadImage('assets/court.jpg');
sadfansImage = loadImage('assets/sadfans.jpg');
happyfansImage = loadImage('assets/happyfans.jpg');
}
function setup() {
createCanvas(1280, 720);
background(100);
}
function draw() {
if (y > height) {
y = 0;
}
if(screen == 0){
startScreen()
}else if(screen == 1){
gameOn()
}else if(screen==2){
endScreen()
}
}
function startScreen(){
background(happyfansImage)
textAlign(CENTER);
fill('white');
strokeWeight(4);
stroke(51);
textSize(32);
text('Welcome to the ASU championship match!', width / 2, height / 2)
text('CLICK HERE TO START TRY AND WIN THE CHAMPIONSHIP FOR ASU!', width / 2, height / 2 + 40);
reset();
}
function gameOn(){
background(courtImage)
text("POINTS = " + score, 100,40)
strokeWeight(4);
stroke(51);
textSize(36);
image(ballImage,x-10,y-10,50,50)
image(hoopImage,mouseX,height-30,60,40)
y+= speed;
if(y>height){
screen =2
}
if(y>height-10 && x>mouseX-20 && x<mouseX+20){
y=-20
speed+=.5
score+= 1
}
if(y==-20){
pickRandom();
}
}
function pickRandom(){
x= random(20,width-20)
}
function endScreen(){
background(sadfansImage)
textAlign(CENTER);
text('ASU LOST', width / 2, height / 2)
strokeWeight(4);
stroke(51);
text("Your points this match = " + score, width / 2, height / 2 + 40)
text('Click anywhere to try and win for the sun devils again!', width / 2, height / 2 + 60);
}
function mousePressed(){
if(screen==0){
screen=1
}else if(screen==2){
screen=0
}
}
function reset(){
score=0;
speed=2;
y=-20;
}