import ddf.minim.*; import ddf.minim.signals.*; import ddf.minim.analysis.*; import ddf.minim.effects.*; import processing.opengl.*; AudioSnippet extsound; AudioSnippet amb; AudioSnippet engine; AudioSnippet explosion; AudioSnippet startSnd; AudioSnippet [] treeSnd; Minim minim; int titleUp = 3; PImage dozer; PImage sky; PImage grass; PImage [] treeimages; PFont font; String [] species; String story = "THE STORY:\n\n\nDEAR SIR OR MADAM,\n\nYOUR PREVIOUS EMPLOYER,\nBOB'S MONSTER TRUCK MADNESS INC,\nSAYS YOU ARE THEIR BEST DRIVER.\nTHE RAINFOREST STANDS BETWEEN\nUS AND MILLIONS OF DOLLARS.\nREMOVE IT FOR US.\n\nSINCERELY,\nULTRACOM AGRICULTURAL CO."; String instructions = "INSTRUCTIONS\n\n\nUPROOT TREES FOR FUN AND $$$!\nPRESS RIGHT ARROW\nTO DRIVE/SWEET JUMPS\n\nPRESS ENTER TO START"; int cash = 0; float start = 0; float offset = 0; int [] heights; float extinctionTimer = 0; String extinctionText = ""; class Tree { public float fallTimer; public boolean falling; PImage img; void Update() { if(falling) { fallTimer--; } } void Draw(float x, float y) { if(fallTimer > 0) { tint(255,128 + (fallTimer/90)*128); pushMatrix(); translate(x,y-50); rotate(radians(90-fallTimer)); image(img,0,0); popMatrix(); noTint(); } } }; Tree [] trees; float speed = 0; float accel = 0; float dozerWheel1; float dozerWheel2; float mindozerWheel1; float mindozerWheel2; float g = 0.1; float v = 0; boolean inAir = false; void GetWheelHeights() { mindozerWheel1 = heights[(width/2-14+int(start))%(width+128)]; mindozerWheel2 = heights[(width/2+14+int(start))%(width+128)]; float jump = max(-(mindozerWheel2 - mindozerWheel1)*speed,-speed); if(inAir == false) { v = jump; } v+=g; dozerWheel1 = dozerWheel1 + v; dozerWheel2 = dozerWheel2 + v; inAir = true; if(abs(mindozerWheel1 - dozerWheel1)<64&&abs(mindozerWheel2 - dozerWheel2)<64) { for(int i=width/2+int(start);i0) { cash+=100; int snd = int(random(0,3)); if(!treeSnd[snd].isPlaying()) { treeSnd[snd].rewind(); treeSnd[snd].play(); } if(cash%5000 == 0) { extsound.rewind(); extsound.play(); extinctionTimer = 300; extinctionText = "The "+species[int(random(0,10))]+" "+species[int(random(10,20))]+" "+species[int(random(20,30))]+"\n is now extinct!"; } trees[(i)%(width+128)].falling = true; } } } if(dozerWheel1 >= mindozerWheel1) { dozerWheel1 = mindozerWheel1; inAir = false; v = 0; } if(dozerWheel2 >= mindozerWheel2) { dozerWheel2 = mindozerWheel2; //inAir = false; //v = 0; } } void setup() { size(640,480,OPENGL); hint(DISABLE_DEPTH_TEST); hint(DISABLE_OPENGL_2X_SMOOTH); heights = new int[width+128]; for(int i=0;i0) { if(titleUp==3) { textFont(font,92); DrawShadowedText(15,height/2-80,"RAINFOREST \n STUNT DOZER!",color(255,0,0)); textFont(font,42); DrawShadowedText(105,height/2+75,"PRESS ENTER TO START!",color(255)); } else if(titleUp==2) { DrawShadowedText(0,50,story,color(255)); } else if(titleUp==1) { DrawShadowedText(0,50,instructions,color(255)); } } else { float index = 0; stroke(0,255,0); //fill(0,255,0); beginShape(QUADS); noTint(); //noFill(); noStroke(); texture(grass); for(int i=int(start);i97) { trees[int(i)%(width+128)].falling = false; trees[int(i)%(width+128)].fallTimer = 90; trees[int(i)%(width+128)].img = treeimages[int(random(0,3))]; } else { trees[int(i)%(width+128)].falling = false; trees[int(i)%(width+128)].fallTimer = 0; } offset++; } speed += accel; speed *= 0.99; extinctionTimer--; if(extinctionTimer > 0) { DrawShadowedText(10,height/2,extinctionText,color(255,0,0)); } if(speed>5) { speed = 5; } if(speed<=2) { engine.loop(1); engine.pause(); } else { if(!engine.isPlaying()) { engine.loop(0); engine.play(); } } if(start>=width+128) { start = 0; } DrawShadowedText(10,25,"CASH: $"+str(cash),color(255)); } } void keyPressed() { if(keyCode == RIGHT) { accel = 0.1; } } void keyReleased() { if(titleUp>0) { titleUp--; startSnd.play(); } else if(keyCode == RIGHT) { accel = 0; } } void stop() { startSnd.close(); engine.close(); amb.close(); extsound.close(); minim.stop(); super.stop(); }