/////////////////////
//Leon Hong
//Proj 3
//10 sec Game
//Experience Mr. Zephyr
//November 20, 2004
/////////////////////
float mx;
float my;
float zeppi;
float KY, KY0;
float KX, KX0;
float delay = 20.0;
boolean done;
int begin;
PImage front = loadImage ("front.jpg");
PImage back = loadImage ("back.gif");
PImage mouse = loadImage ("mouse.gif");
PImage bg = loadImage ("bg.jpg");
PImage land1 = loadImage ("land1.jpg");
PImage land2 = loadImage ("land2.jpg");
PImage land3 = loadImage ("land3.jpg");
PImage land1alpha = loadImage ("land1alpha.jpg");
PImage land2alpha = loadImage ("land2alpha.jpg");
PImage land3alpha = loadImage ("land3alpha.jpg");
PImage sea = loadImage ("sea.jpg");
PImage seaalpha = loadImage ("seaalpha.jpg");
PImage sky = loadImage ("sky.jpg");
PImage zep = loadImage ("zep.jpg");
PImage zepalpha = loadImage ("zepalpha.jpg");
PImage clouds1 = loadImage ("clouds1.jpg");
PImage clouds2 = loadImage ("clouds2.gif");
PImage clouds1alpha = loadImage ("clouds1alpha.jpg");
PImage clouds2alpha = loadImage ("clouds2alpha.jpg");
PImage arm = loadImage ("arm.jpg");
PImage armalpha = loadImage ("armalpha.jpg");
int curTime;
void setup()
{
noCursor();
size (600,300);
noStroke();
alpha(land1, land1alpha);
alpha(land2, land2alpha);
alpha(land3, land3alpha);
alpha(sea, seaalpha);
alpha(zep, zepalpha);
alpha(clouds1, clouds1alpha);
alpha(clouds2, clouds2alpha);
alpha(arm, armalpha);
}
int poocount = 0;
float zoom, plax;
int level=1;
int count=0;
void draw()
{
if (level == 1){
level1();
}
else if (level==2 || level==3){
level2();
}
else if (level==4){
level4();
begin = millis();
}
}
void level1(){
background(front);
if(mousePressed == true && keyPressed == true){
mousePressed=false;
level=2;
}
interpolate(mouseX, mouseY);
translate(520,90);
translate(mx/10,my/5,2);
imageMode(CENTER);
push();
image(mouse,0,0);
pop();
}
int army=0;
void level2(){
poocount=0;
timer();
push();
flying();
pop();
push();
clouds();
pop();
push();
if(mousePressed==true){
//armx=1000;
//interpolate(armx, mouseY);
arm();
}
pop();
if (done == true){
level=4;
}
else{
level=3;
}
}
void level4(){
push();
tint(255,poocount);
image(back,300,150);
pop();
if(mousePressed==true){
mousePressed=false;
level=2;
done = false;
}
if(poocount <255){
poocount++;
}
}
float armx;
void arm(){
armx=mx;
scale(.8);
tint(255,255);
translate(150,470-armx/5);
image(arm,0,0);
scale(-1,1);
translate(-500,20);
image(arm,0,0);
timer();
}
void clouds(){
imageMode(CORNER);
push();
translate (0,mx/3);
scale (1.04,1);
image (clouds2,0,0);
pop();
imageMode(CENTER);
push();
translate(-2,0);
scale(1.0012+mx*2/1500);
image (clouds1, 299,150);
pop();
}
void flying(){
background(26,38,54);
tint(255,254);
interpolate(mouseX, mouseY);
imageMode(CORNER);
push();
translate(-1500, -1200, -1000);
push();
scale(6);
image(sky,0,((my/2.7)));
pop();
scale(10);
fill (80,129, 195);
rect(0,((my/2.7))-250,600, 250);
pop();
zoom = -300+(mx-300);
plax = constrain(-50+my/7,-50,47);
imageMode(CORNER);
translate (-100,0, -abs(zoom));
push();
translate (KX, 0);
push();
push();
translate (90,120,-5);
scale(1.33);
image(sea,-300,-400);
pop();
translate (0,0,-1);
push();
scale(1.33);
image(land3,0,50+plax);
pop();
push();
if(zeppi<1500){
zeppi = zeppi+(abs(mx)/10);
}
else{
zeppi=-600;
}
translate(zeppi, -300);
scale(1.5);
image(zep,0,50);
pop();
push();
scale(1.33);
image(land2,0,0);
pop();
translate (0,0,1);
push();
scale(1.33);
image(land1,0,-50-plax/.9);
pop();
pop();
pop();
}
void interpolate(float dx, float dy)
{
float diffx = dx-mx;
if(abs(diffx) > 1) {
mx = constrain(mx + diffx/delay,15,1000);;
}
float diffy = dy-my;
if(abs(diffy) > 1 && mouseY <295) {
my = my + diffy/delay;
}
}
void timer()
{
if (level==2){
begin = millis();
}
curTime = millis();
if(curTime > begin + 10000) {
done = true;
}
}