blinker_182
YaBB Newbies
Offline
Posts: 10
export problem
Oct 18th , 2009, 3:42am
Hello... Im having a problem when im trying to export... whenever i export and view the html page, my program is just black, it works fine in processing... but when i export it breaks, can anyone give me a hand ? my code is PImage baddy; //images PImage viper; int numOfStars = 100; //new star array pulled from the class Star[] st = new Star[numOfStars]; int centerxPos = 50; int centeryPos = 50; int starsDistance = 500; //distance between the stars float starsSpeed = 1 ; //speed of the stars shoot[] B; int num_shoots=10,shoot_check=-1; //number of bullets, and check the shhot amount baddy[] R; //baddy array pulled from the class int num_baddys=5, baddy_check=-1; //number of bullets, and check the shhot amount boolean hit=false; // the baddy has not been hit yet void setup(){ noCursor(); smooth(); size(600,600); //start the stars noStroke(); centerxPos=height/2; centeryPos=width/2; for(int i = 0; i < numOfStars; i += 1){ st[i] = new Star(); } //start the shooting or bullets B = new shoot[50]; for(int i=0;i<num_shoots;i++) { B[i] = new shoot(); } //star the baddies R = new baddy[num_baddys]; for(int i=0;i<num_baddys;i++) { R[i] = new baddy(); R[i].baddy_size = int(random(50,5)); } } void draw(){ background(1); // background colour //draw the baddies random position baddyCheck(); // draw the shooting for(int i=0;i<num_shoots;i++) { if(B[i].bflag==1) { B[i].shoot_ypos-=5; fill(0,0,255); B[i].shoot_display(); } if(B[i].shoot_ypos<0) {B[i].bflag=0;} } // draw the baddies for(int j=0;j<num_baddys;j++) { if(R[j].rflag==1) { R[j].baddy_ypos+=R[j].speed; R[j].baddy_display(); } if(R[j].baddy_ypos>600) {R[j].rflag=0;} } //if the baddies get hit, call the collision class hit = collision(); for(int i = 0; i < numOfStars; i+= 1){ st[i].starDraw(); //draw stars } // if h is pressed you go into hyper drive if(keyPressed) { if (key == 'h' || key == 'H') { starsSpeed = 10; } } //if s is pressed you go back to normal speed if(keyPressed) { if (key == 's' || key == 'S') { starsSpeed = 1; } } //ship image viper = loadImage("viper.png"); image(viper,mouseX-42,450); //map the ship to the mouse and lock it to the bottom of the screen } // collision, if the bullet hits the baddy, remove the baddy boolean collision() { for(int i=0; i<num_shoots; i++) { for(int j=0; j<num_baddys; j++) { float dx =R[j].baddy_xpos-B[i].shoot_xpos; float dy =R[j].baddy_ypos-B[i].shoot_ypos; float distance=dx*dx + dy*dy; if(distance<= R[j].baddy_size * R[j].baddy_size) { R[j].baddy_ypos=-5; R[j].rflag=0; B[i].shoot_ypos=-5; B[i].bflag=0; return(true); // remove the baddy } } } return(false); } //the shoot class class shoot { int shoot_xpos, shoot_ypos; int bflag=0; void shoot_display() { fill (255,0,0); // colour rect(shoot_xpos,shoot_ypos,5,5); //the bullet } } //if mouse pressed check the bullets, if i have enough shoot. void mousePressed() { shoot_check++; if(shoot_check == num_shoots-1) {shoot_check=0;} B[shoot_check].bflag=1; B[shoot_check].shoot_xpos=pmouseX; B[shoot_check].shoot_ypos = 485; } //baddy check, if there are none add one... at random spots. void baddyCheck() { baddy_check = int(random(-1,num_baddys-1)); if(R[baddy_check].rflag!=1) { R[baddy_check].rflag=1; R[baddy_check].baddy_xpos= int(random(0,600)); // random Xpos of the baddies R[baddy_check].baddy_ypos = 0; R[baddy_check].speed = int(random(1,4)); // random speed of the baddies } } // the baddy class class baddy { int baddy_xpos, baddy_ypos,speed,baddy_size; int rflag=0; void baddy_display() //display the baddy { baddy = loadImage("baddy.png"); image(baddy,baddy_xpos,baddy_ypos,50,75); //load the baddy image and map it to the //xpos and ypos, and set the size if(keyPressed) { if (key == 'h' || key == 'H') { speed = 10; } } } } class Star { //position of the stars float xPos = 0, yPos = 0, zPos = 0, sxPos = 0,syPos = 0; void position(){ zPos= random(1 ,600); xPos= random(1 ,600); yPos= random(1 ,600); } //draw the stars void starDraw(){ if (zPos < starsSpeed){ position(); } //this is where the stars start. zPos-=starsSpeed; sxPos=(xPos*starsDistance)/(yPos)-centerxPos+100; syPos=(yPos*starsDistance)/(zPos)-centeryPos+100; if (sxPos <0 | sxPos>width){ position(); } if (syPos < 0 | syPos > height){ position(); } // colour and size of stars fill(255,255,255); rect(sxPos,syPos,1,1); } } i cant give you the images, cuz im unable to post links yet.