/*
CINDY CHI
OCTOBER 13, 2008
DMA 28: INTERACTIVITY
EXCERCISE F
Inspired by my love for all things magical as well as my obsession with
the boy-who-lived (a.k.a. Harry Potter).
This is an alphabet book from A-E of spells and charms from Harry Potter.
The user presses a letter to change to the corresponding page. Each page
is interactive according to what the spell does. All pages were drawn in
Photoshop and are simplistic to give a lighthearted feel.
*/
int page = 0;
PFont lumos;
PFont orator;
PImage begin;
//Declaring for A.
PImage harry;
PImage broom;
//Declaring for B.
PImage cedric;
PImage bubble;
//Declaring for C.
PImage ron;
PImage angry;
PImage happy;
//Declaring for D.
PImage voldy;
PImage deatheater;
PImage poof;
//Declaring for E.
PImage hermione;
PImage dementor;
PImage unsuccessful;
PImage successful;
void setup()
{
size(400, 400);
smooth();
noStroke();
frameRate(10);
begin = loadImage("beginpage.gif");
//Font setup
lumos = loadFont("Lumos-36.vlw");
orator = loadFont("OratorStd-11.vlw");
//Laoding images for A.
harry = loadImage("a_harry.png");
broom = loadImage("a_broom.png");
//Loading images for B.
cedric = loadImage("b_cedric.gif");
bubble = loadImage("b_bubble.png");
//Loading images for C.
ron = loadImage("c_ron.gif");
angry = loadImage("c_angry.png");
happy = loadImage("c_happy.png");
//Loading images for D.
voldy = loadImage("d_voldy.png");
deatheater = loadImage("d_deatheater.png");
poof = loadImage("d_poof.png");
//Loading images for E.
hermione = loadImage("e_hermione.png");
dementor = loadImage("e_dementor.png");
unsuccessful = loadImage("e_unsuccessful.png");
successful = loadImage("e_successful.png");
}
void draw()
{
//A is for Accio
if(page == 1)
{
background(200);
image(harry, -30, 0);
image(broom, 20, 0);
//Text
textFont(lumos);
fill(255);
text("Accio", 20, 40);
textFont(orator);
fill(121, 0, 0);
text("Press left arrow key give Harry his Firebolt.", 20, 60);
if(key == CODED)
{
if(keyCode == LEFT)
{
page = 11;
}
}
}
//A after the broom has been given to Harry.
else if (page == 11)
{
background(200);
image(broom, -250, 0);
image(harry, -30, 0);
//Text
textFont(lumos);
text("Success!", 20, 40);
textFont(orator);
text("Now Harry can complete the first task!", 20, 60);
}
//B is for Bubblehead Charm.
else if(page == 2)
{
image(cedric, 0, 0);
//Text
textFont(lumos);
fill(255);
text("Bubblehead Charm", 20, 40);
textFont(orator);
fill(121, 0, 0);
text("Click on Cedric's head to cast a bubblehead charm", 20, 60);
text("so he can breathe.", 20, 70);
if(mouseX > 105 && mouseX < 199 && mouseY > 90 && mouseY < 181)
{
if(mousePressed == true)
{
page = 22;
}
}
}
//B after mouse is pressed.
else if(page == 22)
{
image(cedric, 0, 0);
image(bubble, 0, 0);
//Text
textFont(lumos);
text("Success!", 20, 40);
textFont(orator);
text("Now Cedric can save Cho Chang!", 20, 60);
}
//C is for Cheering Charm.
else if(page == 3)
{
image(ron, 0, 0);
image(angry, 0, 0);
//Text
textFont(lumos);
fill(255);
text("Cheering Charm", 20, 40);
textFont(orator);
fill(121, 0, 0);
text("Hold down mouse and move around to fill window with", 20, 60);
text("every-flavor jellybeans until Ron cheers up.", 20, 70);
if(mousePressed == true)
{
page = 33;
}
}
//C after mouse is pressed (draws jellybeans).
else if(page == 33)
{
if(mousePressed == true)
{
fill(random(255), random(255), random(255)); //represents different flavors
ellipse(mouseX, mouseY, 10, 20);
int cheerup = int(random(100)); //random # to determine when Ron is satisfied
if(cheerup % 100 == 0)
{
page = 333;
}
}
}
//C when Ron cheers up.
else if(page == 333)
{
image(ron, 0, 0);
image(happy, 0, 0);
//Text
fill(121, 0, 0);
textFont(lumos);
text("Success!", 10, 40);
textFont(orator);
text("Ron wants to thank you for the sweets. YUM!", 10, 60);
}
//D is for Disapparate.
else if(page == 4)
{
background(132, 81, 196);
image(voldy, 0, 0);
image(deatheater, 0, 0);
//Text
fill(255);
textFont(lumos);
text("Disapparate", 10, 40);
textFont(orator);
fill(121, 0, 0);
text("Voldemort has summoned the deatheater. Hit 'p'to make", 10, 60);
text("him disapparate.", 10, 70);
if(keyPressed == true)
{
if(key == 'p' || key == 'P')
{
page = 44;
}
}
}
//D after 'p' is pressed.
else if(page == 44)
{
background(132, 81, 196);
image(voldy, 0, 0);
image(poof, 0, 0);
//Text
fill(255);
textFont(lumos);
text("Disapparate", 10, 40);
textFont(orator);
fill(121, 0, 0);
text("Good! Now click near Voldemort to reapparate to him.", 10, 60);
if(mouseX < 338 && mouseX > 248 && mouseY < 388 && mouseY > 293)
{
if(mousePressed == true)
{
page = 444;
}
}
}
else if(page == 444)
{
background(132, 81, 196);
image(voldy, 0, 0);
image(deatheater, 230, 220);
//Text
textFont(lumos);
text("Success!", 10, 40);
textFont(orator);
text("Now the deatheater can do the Dark Lord's bidding.", 10, 60);
}
//E is for Expecto Patronum.
else if(page == 5)
{
background(178, 229, 170);
image(hermione, 0, 0);
image(dementor, 0, 0);
//Text
fill(255);
textFont(lumos);
text("Expecto Patronum", 10, 40);
textFont(orator);
fill(121, 0, 0);
text("Help hermione cast her patronus. First what is her", 10, 60);
text("happiest thought? Press 'r' if you think it's ron.", 10, 70);
text("Press 's' if you think it's studying.", 10, 80);
if(keyPressed == true)
{
if(key == 'r' || key == 'R')
{
page = 55;
}
else if(key == 's' || key == 'S')
{
page = 555;
}
}
}
//E when key pressed is 'r'
else if(page == 55)
{
background(178, 229, 170);
image(hermione, 0, 0);
for(int i = 0; i > -200; i -= 70)
{
image(successful, i, 0);
}
//Text
textFont(lumos);
text("Success!", 10, 40);
textFont(orator);
fill(121, 0, 0);
text("Hermione's otter patronus has driven away the dementor.", 10, 60);
text("You have saved her from the dementor's kiss.", 10, 70);
}
//Homepage.
else if(page == 555)
{
background(178, 229, 170);
image(hermione, 0, 0);
image(dementor, 0, 0);
image(unsuccessful, 0, 0);
//Text
fill(0);
textFont(lumos);
text("Fail!", 10, 40);
textFont(orator);
fill(121, 0, 0);
text("That is not her happiest thought!", 10, 60);
text("Press 'e' to try again.", 10, 70);
}
else
{
image(begin, 0, 0);
//Text
fill(0);
textFont(lumos);
text("Alphabet Magic Book", 10, 40);
textFont(orator);
fill(121, 0, 0);
text("Contains the letters A through E. Letters are:", 10, 60);
text("A for Accio", 10, 80);
text("B for Bubblehead Charm", 10, 90);
text("C for Cheering Charm", 10, 100);
text("D for Disapparate", 10, 110);
text("E for Expecto Patronum", 10, 120);
text("Use your keyboard to navigate through the book.", 10, 140);
}
}
void keyPressed()
{
if(key == 'a' || key == 'A')
{
page = 1;
}
if(key == 'b' || key == 'B')
{
page = 2;
}
if(key == 'c' || key == 'C')
{
page = 3;
}
if(key == 'd' || key == 'D')
{
page = 4;
}
if(key == 'e' || key == 'E')
{
page = 5;
}
}
Cindy-F
on Wednesday, Oct 15, 2008 – 12:51 am
2 Comments
this is so good!!
It’s clear a great deal of effort and energy went into this and it looks great. Did you consider making the interactions with the mouse? It’s difficult to read the small type and then find the right key, when you could just click in the right place.