xxxxxxxxxx
172
var gameState = 'home';
var song;
var x1, x2, r, x=200,y=100,size=250;
function preload(){
song = loadSound('Mystery_tune.mp3');
}
function setup() {
createCanvas(400, 400);
x1 = 0;
x2 = 200;
r = 5;
}
function draw() {
background('cyan');
if(gameState === 'home'){
fill('violet');
rectMode(CENTER);
textSize(30);
stroke(128, 204, 255);
strokeWeight(0.1);
textFont('sans-serif');
for(i=20; i<400; i+= 40){
rect(i,20,36,36,5);
rect(i,60,36,36,5);
rect(i,100,36,36,5);
rect(i,140,36,36,5);
rect(i,180,36,36,5);
rect(i,220,36,36,5);
rect(i,260,36,36,5);
rect(i,300,36,36,5);
rect(i,340,36,36,5);
rect(i,380,36,36,5);
}
fill(255);
for(i=20; i<400; i+= 40){
text('?',i-8,31);
text('?',i-8,71);
text('?',i-8,111);
text('?',i-8,151);
text('?',i-8,191);
text('?',i-8,231);
text('?',i-8,271);
text('?',i-8,311);
text('?',i-8,351);
text('?',i-8,391);
}
filter(BLUR, 1.5);
rect(200,197,300,50,10);
rect(200,299,245,35,10);
fill(0);
textSize(35);
textFont('Times New Roman');
text('MYSTERY GAME', 60, 210);
fill(0);
textSize(25);
textFont('Times New Roman');
textAlign(CENTER);
text('Click anywhere to start',205,350,250,125);
textAlign(LEFT);
song.play();
if(mouseIsPressed && mouseButton === LEFT || touches.length > 0 && gameState === 'home'){
touches = [];
gameState = 'started';
}
}
if(gameState === 'started'){
fill('violet');
rectMode(CENTER);
textSize(30);
stroke(128, 204, 255);
strokeWeight(0.1);
textFont('sans-serif');
for(i=20; i<400; i+= 40){
rect(i,20,36,36,5);
rect(i,60,36,36,5);
rect(i,100,36,36,5);
rect(i,140,36,36,5);
rect(i,180,36,36,5);
rect(i,220,36,36,5);
rect(i,260,36,36,5);
rect(i,300,36,36,5);
rect(i,340,36,36,5);
rect(i,380,36,36,5);
}
fill(255);
for(i=20; i<400; i+= 40){
text('?',i-8,31);
text('?',i-8,71);
text('?',i-8,111);
text('?',i-8,151);
text('?',i-8,191);
text('?',i-8,231);
text('?',i-8,271);
text('?',i-8,311);
text('?',i-8,351);
text('?',i-8,391);
}
rect(200,202,300,50,10);
fill(0);
textSize(20);
textFont('Times New Roman');
textAlign(CENTER);
text('Click again and unveil the mysteries of the Universe!', 200, 205, 300,50);
textAlign(LEFT);
if(mouseIsPressed && mouseButton === RIGHT || touches.length > 0){
song.stop();
touches = [];
gameState = 'blasted';
}
}
if(gameState === 'blasted'){
fill('violet');
noStroke();
if(frameCount % 1 === 0){
x1 -= 1;
x2 += 1;
r += 2.5;
}
ellipseMode(CENTER);
rectMode(CORNER);
ellipse(200,200,r);
rect(x1,x1,200,200);
rect(x1,x2,200,200);
rect(x2,x1,200,200);
rect(x2,x2,200,200);
if(r >= 550){
fill('cyan');
beginShape();
vertex(x, y);
bezierVertex(x - size / 2, y - size / 2, x - size, y + size / 3, x, y + size);
bezierVertex(x + size, y + size / 3, x + size / 2, y - size / 2, x, y);
endShape(CLOSE);
fill('violet');
strokeWeight(2.5);
textSize(25);
textFont('Times New Roman');
textAlign(CENTER);
text('Happy Anniversary!!!'+'\n'+'From Bub and Rhea, with love :)', 100,130,200,150);
}
}
if(mouseIsPressed && mouseButton === CENTER){
console.log(r);
}
}