class entities{ public: int x, y, t; //parameters int p1, p2, p3, p4, p5, p6; }; int numentities; entities entity[200]; void addentity(int xp, int yp, int tp, int p1=0, int p2=0, int p3=0, int p4=0, int p5=320, int p6=240){ entity[numentities].x=xp; entity[numentities].y=yp; entity[numentities].t=tp; entity[numentities].p1=p1; entity[numentities].p2=p2; entity[numentities].p3=p3; entity[numentities].p4=p4; entity[numentities].p5=p5; entity[numentities].p6=p6; numentities++; } void naddentity(int xp, int yp, int tp, int p1=0, int p2=0, int p3=0, int p4=0, int p5=320, int p6=240){ entity[numentities].x=xp; entity[numentities].y=yp; entity[numentities].t=tp; entity[numentities].p1=p1; entity[numentities].p2=p2; entity[numentities].p3=p3; entity[numentities].p4=p4; entity[numentities].p5=p5; entity[numentities].p6=p6; } void copyentity(int a, int b){ entity[a].x=entity[b].x; entity[a].y=entity[b].y; entity[a].t=entity[b].t; entity[a].p1=entity[b].p1; entity[a].p2=entity[b].p2; entity[a].p3=entity[b].p3; entity[a].p4=entity[b].p4; entity[a].p5=entity[b].p5; entity[a].p6=entity[b].p6; } void removeentity(int t){ if(t==numentities-1){ numentities--; }else{ for(int m=t;m2); j++){ for(int i=0; i<40; i++){ file >> mapcontents[i][j]; } } file >> p; numentities=0; for(int i=0; i> temp; file >> temp2; file >> temp3; switch(temp3){ case 1: case 2: //Enemy, or platform file >> p1; file >> p2; file >> p3; file >> p4; file >> p5; file >> p6; addentity(temp,temp2,temp3,p1,p2,p3,p4,p5,p6); break; case 10: case 11: case 12: //Save point file >> p1; addentity(temp,temp2,temp3,p1); break; default: addentity(temp,temp2,temp3); break; } } file.close(); return true; } void supersavemap(){ //holy crap int tmpx, tmpy; int ccount=0, scount=0; string s = "overworld.txt"; ofstream file; file.open(s.c_str(), ios::trunc); tmpx=mapx; tmpy=mapy; for(int i=0; i<20; i++){ for(int j=0; j<20; j++){ if(existmap(i,j)){ mapx=i; mapy=j; loadmap(i+100,j+100); scount=0; file << "case rn("<< its(mapx) << ","<< its(mapy) << "):\n"; file << "tmap = new Array();\n"; for(int j=0; j<30; j++){ file << "tmap.push(\""; for(int i=0; i<39; i++){ file << mapcontents[i][j] << ","; } file << mapcontents[39][j] << "\");\n"; } //file << "fillcontent(tmap);\n"; if(numentities>0){ file << "\n"; for(int i=0; i>>"; }else if(entity[i].p1==6){ file << "obj.createentity(game, " << (entity[i].x*8) << ", " << (entity[i].y*8) << ", 2, 9, " << entity[i].p2 << "); //Threadmill, <<<"; }else if(entity[i].p1==7){ file << "obj.createentity(game, " << (entity[i].x*8) << ", " << (entity[i].y*8) << ", 2, 10, " << entity[i].p2 << "); //Big Threadmill, >>>>>>"; }else if(entity[i].p1==8){ file << "obj.createentity(game, " << (entity[i].x*8) << ", " << (entity[i].y*8) << ", 2, 11, " << entity[i].p2 << "); //Big Threadmill, <<<<<<"; } entity[i].t=2; //So that it doesn't disapear from the editor break; case 8: //coin //file << ", " << entity[i].p1 << ", coin"); // (coins)"; //ccount++; break; case 9: //shiny file << ", " << ccount <<"); // (shiny trinket)"; ccount++; break; case 10: //Save point if(entity[i].x==0 && entity[i].y==0){ file << "roomtileset = 0; // (Use space station tileset)"; }else{ file << ", " << entity[i].p1 << ", " << int(scount+((mapx+(mapy*100))*10)) << "); // (savepoint)"; scount++; } break; case 11: //Horizontal if(entity[i].x==0){ file << ", " << entity[i].p1+8 <<"); // (horizontal gravity line)"; }else{ file << ", " << entity[i].p1 <<"); // (horizontal gravity line)"; } break; case 12: //Vertical if(entity[i].y==0){ file << ", " << entity[i].p1+8 <<"); // (vertical gravity line)"; }else{ file << ", " << entity[i].p1 <<"); // (vertical gravity line)"; } break; case 13: //Warp Token entity[i].t=9; file << "obj.createentity(game, " << (entity[i].x*8) << ", " << (entity[i].y*8) << ", 13); //Warp Token"; break; case 14: //Warp Token aid entity[i].t=8; break; default: file << ", behave, para);"; break; } file << "\n"; } } //this bit only if in the lab: temp=-1; for(int j=0; j<30; j++){ for(int i=0; i<39; i++){ if(temp==-1){ if(mapcontents[i][j]==280) temp=0; if(mapcontents[i][j]==283) temp=1; if(mapcontents[i][j]==286) temp=2; if(mapcontents[i][j]==289) temp=3; if(mapcontents[i][j]==292) temp=4; if(mapcontents[i][j]==295) temp=5; } } } //if(temp>=0){ // file << "rcol="<=80 && mapcontents[i2][j2]<280){ putpixel(worldmap, i2+(i*40), j2+(j*30), makecol(164,164,164)); }else if(mapcontents[i2][j2]>=280 && mapcontents[i2][j2]<680){ putpixel(worldmap, i2+(i*40), j2+(j*30), makecol(128,128,128)); }else{ putpixel(worldmap, i2+(i*40), j2+(j*30), makecol(64,64,64)); } } } } } } //Ok, we have a complete map, now output it! savescreen(worldmap); mapx=tmpx; mapy=tmpy; file.close(); } void savemap(){ int ccount=0, scount=0; temp=areamap[mapx-100][mapy-100]; switch(temp){ case 0: currentarea="unset"; break; case 1: currentarea="other"; break; case 2: currentarea="lab"; break; case 3: currentarea="tower"; break; case 4: currentarea="warp"; break; case 5: currentarea="spacestation2"; break; } if(temp==0){ temp=1; areamap[mapx-100][mapy-100]=1; currentarea="other"; saveareamap(); } if(temp<2){ savemapsimple(); string s = "maps/"+currentarea+"/x"+its(mapx)+"y"+its(mapy)+".txt"; ofstream file; file.open(s.c_str(), ios::trunc); file << "case rn("<< its(mapx) << ","<< its(mapy) << "):\n"; file << "tmap = new Array();\n"; for(int j=0; j<30; j++){ file << "tmap.push(\""; for(int i=0; i<39; i++){ file << mapcontents[i][j] << ","; } file << mapcontents[39][j] << "\");\n"; } //file << "fillcontent(tmap);\n"; if(numentities>0){ file << "\n"; for(int i=0; i>>"; }else if(entity[i].p1==6){ file << "obj.createentity(game, " << (entity[i].x*8) << ", " << (entity[i].y*8) << ", 2, 9, " << entity[i].p2 << "); //Threadmill, <<<"; }else if(entity[i].p1==7){ file << "obj.createentity(game, " << (entity[i].x*8) << ", " << (entity[i].y*8) << ", 2, 10, " << entity[i].p2 << "); //Big Threadmill, >>>>>>"; }else if(entity[i].p1==8){ file << "obj.createentity(game, " << (entity[i].x*8) << ", " << (entity[i].y*8) << ", 2, 11, " << entity[i].p2 << "); //Big Threadmill, <<<<<<"; } entity[i].t=2; //So that it doesn't disapear from the editor break; case 8: //coin //file << ", " << entity[i].p1 << ", coin+"<=0){ // file << "rcol="<=0 && x<40 && y>=0 && y<30){ mapcontents[x][y]=t; } } int at(int x, int y){ if(x>=0 && x<40 && y>=0 && y<30){ return mapcopycontents[x][y]; } if(x==-1) return at(x+1,y); if(x==40) return at(x-1,y); if(y==-1) return at(x,y+1); if(y==30) return at(x,y-1); return 0; } int match(int x, int y, int t){ //Returns the first position match for a border // 5 1 6 // 2 X 4 // 7 3 8 if(at(x-1,y)!=t && at(x,y-1)!=t) return 10; if(at(x+1,y)!=t && at(x,y-1)!=t) return 11; if(at(x-1,y)!=t && at(x,y+1)!=t) return 12; if(at(x+1,y)!=t && at(x,y+1)!=t) return 13; if(at(x,y-1)!=t) return 1; if(at(x-1,y)!=t) return 2; if(at(x,y+1)!=t) return 3; if(at(x+1,y)!=t) return 4; if(at(x-1,y-1)!=t) return 5; if(at(x+1,y-1)!=t) return 6; if(at(x-1,y+1)!=t) return 7; if(at(x+1,y+1)!=t) return 8; return 0; } bool inbox(int x1, int y1, int x2, int y2, int xt, int yt){ if(xt>=x1 && xt=y1 && yt=880 && t<920){ temp=t-880; }else if(t>=680 && t<720){ temp=t-680; }else if(t>=480 && t<520){ temp=t-480; }else if(t>=280 && t<320){ temp=t-280; }else if(t>=80 && t<120){ temp=t-80; }else{ return t; } if(temp%3==0){ //we have a candidate for edginess! switch(match(x,y,t)){ case 10: return t+80; break; case 11: return t+82; break; case 12: return t+160; break; case 13: return t+162; break; case 1: return t+81; break; case 2: return t+120; break; case 3: return t+161; break; case 4: return t+122; break; case 5: return t+42; break; case 6: return t+41; break; case 7: return t+2; break; case 8: return t+1; break; case 0: default: return t; break; } } return t; } void drawentities(){ temp=entat(xp,yp); for(int i=0; i