/*
CINDY CHI
NOV. 10, 2008
DMA 28: INTERACTIVITY
PROJECT 2
The goal of the game is to try and complete the task you are given.
In order to do so the player must figure out the odd pattern of the
doors. Each door will lead you to somewhere unexpected until the
player has figured out the rule each door follows.
The first task is just to familiarize the player with the pattern of
the doors. The goal is to reach the bedroom.
The second task is to retrieve the 5 pictures that are misplaced.
*/
//Load images.
PImage start; //start page
PImage round2; //instructions for round 2
PImage gamesuccess; //when completes second round
PImage house;
PImage opendoor; //when player is in front of a door
PImage house2; //for round2
PImage character;
PImage character_reverse; //when character changes direction
//Missing pictures
PImage pic1;
PImage pic2;
PImage pic3;
PImage pic4;
PImage pic5;
//Keeping track of things
int page = 0; //start page, levels, etc.
int door; //keeps track of which door
int level = 1;
int prev_move = 0; //keeps track of player's move
int direction = 1; //direction of player's movement in each room
int x = 0; //moves character
int counter = 1; //for door 13
//Picture placement
float pic1X = 0;
float pic1Y = 0;
float pic1_targetX = 50;
float pic1_targetY = 196;
float pct1 = 0;
float pic2X = 0;
float pic2Y = 0;
float pic2_targetX = -140;
float pic2_targetY = 200;
float pct2 = 0;
float pic3X = 0;
float pic3Y = 0;
float pic3_targetX = -293;
float pic3_targetY = 100;
float pct3 = 0;
float pic4X = 0;
float pic4Y = 0;
float pic4_targetX = -283;
float pic4_targetY = 5;
float pct4 = 0;
float pic5X = 0;
float pic5Y = 0;
float pic5_targetX = -115;
float pic5_targetY = -80;
float pct5 = 0;
float step = .01;
//Booleans for moving around and click in each room
Boolean kitchen = false;
Boolean game = false;
Boolean study = true;
Boolean bedroom = false;
Boolean bathroom = false;
Boolean living = false;
Boolean garage = false;
Boolean open_door = false; //keeps track of when the door is opened
Boolean come_in = false; //determines when character comes in from a door, sets x
//Booleans for recovering pictures
Boolean recover_pic1 = false;
Boolean recover_pic2 = false;
Boolean recover_pic3 = false;
Boolean recover_pic4 = false;
Boolean recover_pic5 = false;
void setup()
{
size(600, 400);
noCursor();
//loading info pages
start = loadImage("start.gif");
round2 = loadImage("round2.gif");
//loading house images
house = loadImage("house.gif");
opendoor = loadImage("opendoor.gif");
house2 = loadImage("house2.gif");
gamesuccess = loadImage("gamesuccess.gif");
character = loadImage("character.png");
character_reverse = loadImage("character_reverse.png");
pic1 = loadImage("pic1.gif");
pic2 = loadImage("pic2.gif");
pic3 = loadImage("pic3.gif");
pic4 = loadImage("pic4.gif");
pic5 = loadImage("pic5.gif");
}
void draw()
{
if(page == 1)
{
image(house, 0, 0);
if(level == 2)
{
image(house2, 0, 0);
image(pic1,pic1X,pic1Y);
if(recover_pic1 == true)
{
pct1 += step;
if(pct1 <= 1)
{
pic1X = (pic1_targetX * pct1);
pic1Y = (pic1_targetY * pct1);
println(pct1);
}
}
image(pic2,pic2X,pic2Y);
if(recover_pic2 == true)
{
pct2 += step;
if(pct2 <= 1)
{
pic2X = (pic2_targetX * pct2);
pic2Y = (pic2_targetY * pct2);
println(pct2);
}
}
image(pic3,pic3X,pic3Y);
if(recover_pic3 == true)
{
pct3 += step;
if(pct3 <= 1)
{
pic3X = (pic3_targetX * pct3);
pic3Y = (pic3_targetY * pct3);
println(pct3);
}
}
image(pic4,pic4X,pic4Y);
if(recover_pic4 == true)
{
pct4 += step;
if(pct4 <= 1)
{
pic4X = (pic4_targetX * pct4);
pic4Y = (pic4_targetY * pct4);
println(pct4);
}
}
image(pic5,pic5X,pic5Y);
if(recover_pic5 == true)
{
pct5 += step;
if(pct5 <= 1)
{
pic5X = (pic5_targetX * pct5);
pic5Y = (pic5_targetY * pct5);
println(pct5);
}
}
//when round 2 is completed
if(pct1 > .99 && pct2 > .99 && pct3 > .99 && pct4 > .99 && pct5 > .99)
{
page = 3;
}
}
//Kitchen
if(kitchen == true)
{
//door opens when in front of it
if(x >= 0 && x <= 59)
{
image(opendoor, 12, 18);
}
else if(x >= 219 && x <= 295)
{
image(opendoor, 249, 18);
}
if(come_in == true)
{
//displaying character start point depending on which door it came from
if(door == 1)
{
x = 9;
}
else //if door == 2
{
x = 245;
}
come_in = false;
}
//displaying character direction
if(direction == 1)
{
image(character, x, 39);
}
if(direction == -1)
{
image(character_reverse, x, 39);
}
//move
x += 1 * direction;
if(x >= 276)
{
direction = -1;
}
if(x <= 0)
{
direction = 1;
}
}
//Game
else if(game == true)
{
//if player in front of door then it opens
if(x >= 378 && x <= 453)
{
image(opendoor, 406, 18);
}
else if(x >= 521 && x <= 597)
{
image(opendoor, 550, 18);
}
if(come_in == true)
{
//displaying character start point depending on which door it came from
if(door == 3)
{
x = 404;
}
else //if door == 4
{
x = 547;
}
come_in = false;
}
//displaying character direction
if(direction == 1)
{
image(character, x, 39);
}
if(direction == -1)
{
image(character_reverse, x, 39);
}
//move
x += 1 * direction;
if(x >= 574)
{
direction = -1;
}
if(x <= 304)
{
direction = 1;
}
}
//Study
else if(study == true)
{
//if player in front of door then it opens
if(x >= 133 && x <= 194)
{
image(opendoor, 147, 119);
}
else if(x >= 301 && x <= 377)
{
image(opendoor, 330, 119);
}
else if(x >= 483 && x <= 560)
{
image(opendoor, 512, 119);
}
if(come_in == true)
{
//displaying character start point depending on which door it came from
if(door == 5)
{
x = 133;
}
else if(door == 6)
{
x = 301;
}
else //if door == 7
{
x = 483;
}
come_in = false;
}
//displaying character direction
if(direction == 1)
{
image(character, x, 139);
}
if(direction == -1)
{
image(character_reverse, x, 139);
}
//move
x += 1 * direction;
if(x >= 574)
{
direction = -1;
}
if(x <= 0)
{
direction = 1;
}
}
//Bedroom
else if(bedroom == true)
{
//if player in front of door then it opens
if(x >= 0 && x <= 89)
{
image(opendoor, 12, 218);
}
if(level == 1)
{
if(come_in == true)
{
x = 9;
}
page = 2; //round 2 instructions
}
if(level == 2)
{
if(come_in == true)
{
x = 9;
come_in = false;
}
//displaying character direction
if(direction == 1)
{
image(character, x, 239);
}
if(direction == -1)
{
image(character_reverse, x, 239);
}
//move
x += 1 * direction;
if(x >= 235)
{
direction = -1;
}
if(x <= 0)
{
direction = 1;
}
}
}
//Bathroom
else if(bathroom == true)
{
//if player in front of door then it opens
if(x >= 241 && x <= 317)
{
image(opendoor, 270, 220);
}
else if(x >= 514 && x <= 591) //returns to previous room
{
image(opendoor, 544, 220);
}
if(come_in == true)
{
//displaying character start point depending on which door it came from
if(door == 9)
{
x = 267;
}
else //if door == 10
{
x = 540;
}
come_in = false;
}
//displaying character direction
if(direction == 1)
{
image(character, x, 239);
}
if(direction == -1)
{
image(character_reverse, x, 239);
}
//move
x += 1 * direction;
if(x >= 574)
{
direction = -1;
}
if(x <= 263)
{
direction = 1;
}
}
//Living
else if(living == true)
{
//if player in front of door then it opens
if(x >= 0 && x <= 59) //returns to other door in same room
{
image(opendoor, 12, 321);
}
else if(x >= 265 && x <= 340)
{
image(opendoor, 293, 321);
}
if(come_in == true)
{
//displaying character start point depending on which door it came from
if(door == 11)
{
x = 9;
}
else //if door == 12
{
x = 291;
}
come_in = false;
}
//displaying character direction
if(direction == 1)
{
image(character, x, 339);
}
if(direction == -1)
{
image(character_reverse, x, 339);
}
//move
x += 1 * direction;
if(x >= 326)
{
direction = -1;
}
if(x <= 0)
{
direction = 1;
}
}
//Garage
else if(garage == true)
{
//if player in front of door then it opens
if(x >= 343 && x <= 419)
{
image(opendoor, 372, 321);
}
else if(x >= 514 && x <= 591)
{
image(opendoor, 543, 321);
}
if(come_in == true)
{
//displaying character start point depending on which door it came from
if(door == 13)
{
x = 369;
}
else //if door == 14
{
x = 540;
}
come_in = false;
}
//displaying character direction
if(direction == 1)
{
image(character, x, 339);
}
if(direction == -1)
{
image(character_reverse, x, 339);
}
//move
x += 1 * direction;
if(x >= 574)
{
direction = -1;
}
if(x <= 354)
{
direction = 1;
}
}
}
//ROUND TWO INSTRUCTIONS
else if(page == 2)
{
level = 2;
image(round2, 0, 0);
}
//ROUND TWO COMPLETED
else if(page == 3)
{
image(gamesuccess, 0, 0);
}
else //start page
{
image(start, 0, 0);
}
}
///////////////////////////////////////////////////CLICK CONTROLS
void mousePressed()
{
if(page == 1)
{
//change direction if mouse clicked
direction = -direction;
//Kitchen
if(kitchen == true)
{
if(x >= 0 && x <= 59)
{
game = true;
kitchen = false;
door = 3; //door to go to
come_in = true;
}
else if(x >= 219 && x <= 295)
{
bathroom = true;
kitchen = false;
prev_move = 2;
door = 10; //door to go to
come_in = true;
}
//recovering pic in round 2
if(level == 2)
{
if(x >= 109 && x <= 156)
{
recover_pic1 = true;
}
}
}
//Game
else if(game == true)
{
if(x >= 378 && x <= 453)
{
study = true;
game = false;
door = 6; //door to go to
come_in = true;
}
else if(x >= 521 && x <= 597)
{
garage = true;
game = false;
door = 14; //door to go to
come_in = true;
}
//recovering pic in round 2
if(level == 2)
{
if(x >= 339 && x <= 365)
{
recover_pic2 = true;
}
}
}
//Study
else if(study == true)
{
if(x >= 133 && x <= 194)
{
kitchen = true;
study = false;
door = 1; //door to go to
come_in = true;
}
else if(x >= 301 && x <= 377)
{
bathroom = true;
study = false;
prev_move = 6;
door = 9; //door to go to
come_in = true;
}
else if(x >= 483 && x <= 560)
{
game = true;
study = false;
door = 4; //door to go to
come_in = true;
}
//recovering pic in round 2
if(level == 2)
{
if(x >= 402 && x <= 446)
{
recover_pic3 = true;
}
}
}
//Bedroom
else if(bedroom == true && level == 2)
{
if(x >= 0 && x <= 89)
{
study = true;
bedroom = false;
door = 5;
come_in = true;
}
}
//Bathroom
else if(bathroom == true)
{
if(x >= 241 && x <= 317)
{
garage = true;
bathroom = false;
door = 13; //door to go to
come_in = true;
}
else if(x >= 514 && x <= 591) //returns to previous room
{
println(prev_move);
if (prev_move == 6) //then came from study
{
door = 6;
study = true;
bathroom = false;
}
else if(prev_move == 2) //then came from kitchen
{
door = 2;
kitchen = true;
bathroom = false;
}
else if(prev_move == 12) //then came from living
{
door = 12;
living = true;
bathroom = false;
}
else if(prev_move == 13) //then came from garage
{
door = 13;
garage = true;
bathroom = false;
}
come_in = true;
}
//recovering pic in round 2
if(level == 2)
{
if(x >= 410 && x <= 432)
{
recover_pic4 = true;
}
}
}
//Living
else if(living == true)
{
if(x >= 0 && x <= 59) //returns to other door in same room
{
door = 12; //door to go to
come_in = true;
}
else if(x >= 265 && x <= 340)
{
living = false;
door = int(random(1, 14.99)); //door to go to
println(door);
//Determining what room you get sent to
if(door == 1 || door == 2)
{
kitchen = true;
}
else if(door == 3 || door == 4)
{
game = true;
}
else if(door == 5 || door == 6 || door == 7)
{
study = true;
}
else if(door == 8)
{
bedroom = true;
}
else if(door == 9 || door == 10)
{
bathroom = true;
}
else if(door == 11 || door == 12)
{
door = 11;
living = true;
}
else //if door == 13 || door == 14
{
garage = true;
}
come_in = true;
}
//recovering pic in round 2
if(level == 2)
{
if(x >= 226 && x <= 266)
{
recover_pic5 = true;
}
}
}
//Garage
else //if(garage == true)
{
if(x >= 343 && x <= 419)
{
garage = false;
prev_move = 13;
//Goes to door 12 and then minus one after that.
door = 13 - counter;
counter++;
if(counter > 12)
{
counter = -1;
}
//Determining what room you get sent to
if(door == 1 || door == 2)
{
kitchen = true;
}
else if(door == 3 || door == 4)
{
game = true;
}
else if(door == 5 || door == 6 || door == 7)
{
study = true;
}
else if(door == 8)
{
bedroom = true;
}
else if(door == 9 || door == 10)
{
bathroom = true;
}
else if(door == 11 || door == 12)
{
living = true;
}
else //if door == 13 || door == 14
{
garage = true;
}
come_in = true;
}
else if(x >= 514 && x <= 591)
{
living = true;
garage = false;
door = 12; //door to go to
come_in = true;
}
}
}
else //info pages
{
page = 1;
}
}
Cindy - Project 2
on Monday, Nov 17, 2008 – 12:05 am