star[] stars; ship foo; float xp=0; rock[] rocks; BFont f; int score; int numrocks=30; int numstars=600; int newgame=1; int paused=0; void setup() { size(200,400); f=loadFont("Futura-Light.vlw.gz"); textFont(f,16); background(0); stars=new star[numstars]; for(int i=0;i=0) { background(0); fill(color(0,255,0)); textFont(f,20); stroke(255,255,255); text("Shields:" + foo.shields,2,20); fill(color(255,255,0)); text("Score:" +score,width-80,20); push(); translate(0,height/2); rotateX(PI/5.0); xp+=0.01; score++; for(int i=0;i(foo.y-10) && (rocks[i].y-5foo.x-10 && rocks[i].x-5200) { speed=random(2)+4; x=random(width+30)-15; y=0-2*height; } } void draw() { move(); push(); translate(x,y); rotateZ(r); stroke(0,255,0); line(6,0,4,-8); line(4,-8,-2,-10); line(-2,-10,-8,-4); line(-8,-4,-6,4); line(-6,4,4,6); line(4,6,1,1); line(1,1,6,0); pop(); } } class ship { float x,y; float r; int shields=1000; trail smoke; ship(int _x, int _y) { x=_x; y=_y; smoke=new trail(x,y); } void draw() { smoke.spawn(x,y); smoke.draw(); stroke(0,255,0); x=x+3*sin(r); push(); translate(x,y); rotate(r); line(10,10,0,-10); line(-10,10,0,-10); line(10,10,0,5); line(-10,10,0,5); pop(); } void moveRight() { if(x>(width-25)) moveForward(); else { r=r+PI/20.0; if(r>PI/4.0) { r=PI/4.0; } } } void moveForward() { if(r>0) { r-=(PI/40.0); if(r<0) r=0; } else if(r<0) { r+=(PI/40.0); if(r>0) r=0; } else r=0; } void moveLeft() { if(x<25) moveForward(); else { r=r-(PI/40.0); if(r<(0-(PI/4.0))) { r=0-(PI/4.0); } } } void boom() { shields-=10; push(); translate(x,y); noFill(); stroke(255,255,0); ellipse(-15,-15,30,30); pop(); } } class trail { particle[] bits; int x; trail(float _x, float _y) { x=0; bits=new particle[400]; for(int i=0;i<400;i++) { bits[i]=new particle(_x,_y); } } void draw() { for(int i=0;i200) { y=0-height*2; speed=random(1.7)+0.1; } } void draw() { // set(x,(int)y,0); move(); stroke(color(150*speed+40,150*speed+40,150*speed+40)); line(x,(int)y,x,y+speed); } }