int page = 1;
float x = 0;
float y = 0;
float easing = 0.01;
PImage a;
PImage b;
PImage c;
PImage d;
PImage e;
PImage f;
PImage g;
PImage h;
PImage i;
PImage j;
PImage k;
PImage l;
PImage m;
PImage n;
PImage o;
PImage p;
PImage q;
PImage r;
void setup() {
size(600, 400);
a = loadImage("Cover.png");
b = loadImage("Character page.png");
c = loadImage("Find helper.png");
d = loadImage("Find helper2.png");
e = loadImage("Find helper_1.png");
f = loadImage("Find helper_2.png");
g = loadImage("Find helper_3.png");
h = loadImage("Find shell.png");
i = loadImage("Find helper2_1.png");
j = loadImage("Find helper2_2.png");
k = loadImage("Find helper2_3.png");
l = loadImage("Find green.png");
m = loadImage("Find heart.png");
n = loadImage("End.png");
o = loadImage("Turtle.png");
p = loadImage("Bird.png");
q = loadImage("Helper.png");
r = loadImage("Helper2.png");
}
void draw() {
if (page == 1) { // Cover
background(a);
if ((keyPressed == true) && (key == ENTER)) {
page = 2;
}
}
else if (page == 2) { // Character page
background(b);
}
else if (page == 3) {
background(c);
if ((keyPressed == true) && (key == '1')) {
page = 5;
}
if ((keyPressed == true) && (key == '2')) {
page = 6;
}
if ((keyPressed == true) && (key == '3')) {
page = 7;
}
}
else if (page == 4) {
background(d);
if ((keyPressed == true) && (key == '2')) {
page = 9;
}
if ((keyPressed == true) && (key == '3')) {
page = 10;
}
if ((keyPressed == true) && (key == '1')) {
page = 11;
}
}
else if (page == 5) { // Wrong helper #1
background(e);
if ((keyPressed == true) && (key == BACKSPACE)) {
page = 3;
}
}
else if (page == 6) { // Wrong helper #2
background(f);
if ((keyPressed == true) && (key == BACKSPACE)) {
page = 3;
}
}
else if (page == 7) { // Correct helper #3
background(g);
if ((keyPressed == true) && (key == ENTER)) {
page = 8;
}
}
else if (page == 8) { // Find seashell
float targetX = mouseX;
float targetY = mouseY;
x += (targetX - x) * easing;
y += (targetY - y) * easing;
noCursor();
background(h);
image(q, x, y);
image(o, mouseX-5, mouseY-5);
if ((keyPressed == true) && ( key == BACKSPACE)) {
page = 7;
}
}
else if (page == 9) { // Wrong helper #1
background(i);
if ((keyPressed == true) && ( key == BACKSPACE)) {
page = 4;
}
}
else if (page == 10) { // Wrong helper #2
background(j);
if ((keyPressed == true) && ( key == BACKSPACE)) {
page = 4;
}
}
else if (page == 11) { // Correct helper #3
background(k);
if ((keyPressed == true) && ( key == ENTER)) {
page = 12;
}
}
else if (page == 12) { // Find green leaf
float targetX = mouseX;
float targetY = mouseY;
x += (targetX - x) * easing;
y += (targetY - y) * easing;
noCursor();
background(l);
image(r, x, y);
image(p, mouseX-5, mouseY-5);
if ((keyPressed == true) && ( key == BACKSPACE)) {
page = 11;
}
}
else if (page == 13) { // Find heart
cursor();
background(m);
}
else if (page == 14) { // End
background(n);
if ((keyPressed == true) && ( key == ENTER)) {
page = 2;
}
}
}
void mousePressed() {
if (page == 2) {
if ((mouseX > 305) && (mouseX < 435) && (mouseY > 215) && (mouseY < 400)) {
page = 3;
}
if ((mouseX > 150) && (mouseX < 265) && (mouseY > 115) && (mouseY < 190)) {
page = 4;
}
}
if (page == 8) {
if ((mouseX > 119) && (mouseX < 150) && (mouseY > 360) && (mouseY < 399)) {
page = 13;
}
}
if (page == 12) {
if ((mouseX > 540) && (mouseX < 580) && (mouseY > 365) && (mouseY < 400)) {
page = 13;
}
}
if (page == 13) {
if ((mouseX > 275) && (mouseX < 390) && (mouseY > 100) && (mouseY < 216)) {
page = 14;
}
}
}Charlene - Project 1
on Wednesday, Oct 29, 2008 – 1:40 am