int page = 1;
PImage[] columnOne= new PImage [3];
PImage[] columnTwo= new PImage [3];
PImage[] columnThree= new PImage [3];
PImage screen1;
PImage endscreen1;
PImage endscreen2;
PImage fire1;
PImage fire2;
PImage fire3;
PImage punch1;
PImage punch2;
PImage punch3;
PImage elec1;
PImage elec2;
PImage elec3;
PImage template2;
boolean spin1;
boolean spin2;
boolean spin3;
int image1index;
int image2index;
int image3index;
void setup(){
size (600,400);
frameRate(12);
screen1 = loadImage ("startscreen.jpg");
endscreen1 = loadImage ("end-bad.jpg");
endscreen2 = loadImage ("end-good.jpg");
template2= loadImage ("template2.jpg");
columnOne[0] = loadImage("fire1.jpg");
columnOne[1] = loadImage("punch1.jpg");
columnOne[2] = loadImage("elec1.jpg");
columnTwo[0] = loadImage("fire2.jpg");
columnTwo[1] = loadImage("punch2.jpg");
columnTwo[2] = loadImage("elec2.jpg");
columnThree[0] = loadImage("fire3.jpg");
columnThree[1] = loadImage("punch3.jpg");
columnThree[2] = loadImage("elec3.jpg");
spin1=true;
spin2=true;
spin3=true;
}
void draw(){
if (page == 1){
image (screen1,0,0);
}
else if (page == 2){
image ( template2,0,0);
if (spin1 == true) {
image1index = int(random(0,3));
}
if (spin2 == true) {
image2index = int(random(0,3));
}
if (spin3 == true) {
image3index = int(random(0,3));
}
image(columnOne[image1index],110, 175);
image(columnTwo[image2index],251,175);
image(columnThree[image3index],390, 175);
}
else if (page == 3) {
image (endscreen1,0,0);
}
if (page == 4){
image (endscreen2,0,0);
}
}
void keyPressed(){
if ((key == 'z')){
if (page == 1){
page = 2;
spin1 = true;
spin2 = true;
spin3 = true;
}
else if (page == 2){
if (spin1== true) {
spin1 = false;
}
else if (spin2== true) {
spin2 = false;
}
else if (spin3== true) {
spin3 = false;
}
else gameEnds();
}
else if (page == 3 || page == 4){
page = 1;
}
}
}
void gameEnds(){
if (image1index == 0 &&
image2index == 0 &&
image3index == 0){
page = 4;
}
else if (image1index == 1 &&
image2index == 1 &&
image3index == 1){
page = 4;
}
else if(image1index == 2 &&
image2index == 2 &&
image3index == 2) {
page = 4;
}
else {
page = 3;
}
}
Monica - Project 2
on Wednesday, Nov 19, 2008 – 11:20 am