xxxxxxxxxx
220
var bg;
var ctr;
var gb;
var gbb;
var tv1;
var tv1_button;
var tv2;
var tv2_button;
var chr;
var scr = 1;
var gb_pressed;
var gb_button_pressed;
var gb_hover;
var gb_button;
var arrow;
var anim2;
var bgm;
var button;
function preload() {
bg = loadImage("background.png");
ctr = loadImage("controller.png");
chr = loadImage("character.png");
gbb = loadImage("gameboybig.png");
gb_pressed = loadImage("gb_pressed.png");
gb_button_pressed = loadImage("gb_button_pressed.png");
tv1 = loadImage("tv1.png");
tv2 = loadImage("tv2.png");
gb_hover = loadImage("gameboy_hover.png");
tv1_button = loadImage("tv1_button.png");
tv2_button = loadImage("tv2_button.png");
gb_button = loadImage("gameboybig_button.png");
arrow = loadImage ("arrow.png");
bgm = loadSound("8bit.m4a");
button = loadSound("button.wav");
}
function setup() {
createCanvas(600, 600);
//imageMode(CENTER);
bgm.play();
}
function draw() {
if (scr == 1) {
drawScreen1();
} else if (scr == 2) {
drawScreen2();
} else if (scr == 3) {
drawScreen3();
} else if (scr == 4) {
drawScreen4();
} else if (scr == 5) {
drawScreen5();
}
}
function overRect(x, y, w, h) {
if ((mouseX > x) && (mouseX < x + w) &&
(mouseY > y) && (mouseY < y + h)) {
return true;
} else {
return false;
}
}
function drawScreen1() {
image(bg, 0, 0);
if (overRect(50, 430, 80, 100)) {
image(tv1_button,25,415,130,130)
}
if (overRect(383.5, 480, 60, 40)) {
image(tv2_button,350,460,120,80)
}
if (overRect(494, 419, 64, 102)) {
image(gb_hover,490, 390);
}
if (overRect(223,142,149,140))
{
noStroke();
fill(random(0,255),random(0,255),random(0,255));
rect(223,142,150,142);
}
}
function drawScreen2() {
image(tv1, 0, 0);
if (overRect(50, 430, 80, 100)) {
image(tv1_button,25,415,130,130)
}
if (overRect(383.5, 480, 60, 40)) {
image(tv2_button,350,460,120,80)
}
if (overRect(494, 419, 64, 102)) {
image(gb_hover,490, 390);
}
}
function drawScreen3() {
// noFill();
// if (overRect(333, 344, 50, 50)) {
// fill(150);
// rect(333, 344, 50, 50);
// } else {
// noFill();
// rect(333, 344, 50, 50);
// }
image(tv2, 0, 0);
if (overRect(50, 430, 80, 100)) {
image(tv1_button,25,415,130,130)
}
if (overRect(383.5, 480, 60, 40)) {
image(tv2_button,350,460,120,80)
}
if (overRect(494, 419, 64, 102)) {
image(gb_hover,490, 390);
}
}
function drawScreen4() {
image(gb_pressed, 0, 0);
if (overRect(333, 344, 50, 50)) {
image(gb_button,330,330,80,80);
}
}
function drawScreen5() {
image(gb_button_pressed, 0, 0);
if (overRect(450, 500, 100, 100)) {
image(arrow,477,485,90,90);
}
}
// run single time,
// each time when mouse button is pressed
function mousePressed() {
//when at mario screen
if (scr == 1) {
if (overRect(50, 430, 80, 100)) {
scr = 2;
button.play();
// if (overRect(120, 490, 50, 50)){
// scr = 1;
// }
}
if (overRect(383.5, 480, 60, 40)) {
scr = 3;
button.play();
}
if (overRect(494, 419, 64, 102)) {
scr = 4;
button.play();
}
}
if (scr == 2) {
if (overRect(50, 430, 80, 100)) {
scr = 2;
// if (overRect(120, 490, 50, 50)){
// scr = 1;
// }
button.play();
}
if (overRect(383.5, 480, 60, 40)) {
scr = 3;
button.play();
}
if (overRect(494, 419, 64, 102)) {
scr = 4;
button.play();
}
}
if (scr == 3) {
if (overRect(50, 430, 80, 100)) {
scr = 2;
button.play();
// if (overRect(120, 490, 50, 50)){
// scr = 1;
// }
}
if (overRect(383.5, 480, 60, 40)) {
scr = 3;
button.play();
}
if (overRect(494, 419, 64, 102)) {
scr = 4;
button.play();
}
}
if (scr == 4) {
//button
if (overRect(333, 344, 50, 50)) {
scr = 5;
button.play();
}
}
if (scr == 5) {
if (overRect(450, 500, 100, 100)) {
scr = 1;
button.play();
}
}
}