Advertisement
Guest User

Untitled

a guest
Jan 9th, 2020
3,605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 35.38 KB | None | 0 0
  1. #include <string>
  2. #include <sstream>
  3. #include <fstream>
  4. #include <allegro.h>
  5. #include <loadpng.h>
  6. using namespace std;
  7.  
  8. volatile int speed_counter=0;
  9. void increment_speed_counter(){speed_counter++;}
  10. END_OF_FUNCTION(increment_speed_counter);
  11.  
  12. string currentarea;
  13. PALLETE dummypal;
  14. BITMAP *buffer, *biggerbuffer, *page[3];
  15. BITMAP *tiles[4000];
  16.  
  17. bool test;
  18. string teststring;
  19.  
  20.  
  21. int mapcontents[40][29];
  22. int mapcopycontents[40][29];
  23.  
  24. int xp, yp, ctile;
  25. int reversekey;
  26. int mapx, mapy;
  27. int savednote;
  28. int temp, temp2, temp3, p;
  29.  
  30. int tileselectdelay;
  31. int paraadjustdelay;
  32. string tempstring;
  33.  
  34. bool fullscreen;
  35.  
  36. //Some helpful functions!
  37. string its(int t, int s=0){
  38.   string te;
  39.   ostringstream *its_temp;
  40.   its_temp = new ostringstream;
  41.   (*its_temp) << t;
  42.   te = (*its_temp).str();
  43.   delete its_temp;
  44.   if(s==0){ return te;
  45.   }else{
  46.     int d;
  47.     d=s-te.length();
  48.     if(d<0){
  49.       return te;
  50.     }else{
  51.       while(d>0){
  52.         te = "0" + te;
  53.         d--;
  54.       }
  55.       return te;
  56.     }
  57.   }
  58. }
  59.  
  60. int sti(string s){
  61.   istringstream stringbuf(s);
  62.   int t;
  63.   stringbuf >> t;
  64.   return t;
  65. }
  66.  
  67. class entities{
  68.   public:
  69.   int x, y, t;
  70.   //parameters
  71.   int p1, p2, p3, p4, p5, p6;
  72. };
  73. int numentities;
  74.  
  75. entities entity[200];
  76. 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){
  77.   entity[numentities].x=xp;
  78.   entity[numentities].y=yp;
  79.   entity[numentities].t=tp;
  80.   entity[numentities].p1=p1;
  81.   entity[numentities].p2=p2;
  82.   entity[numentities].p3=p3;
  83.   entity[numentities].p4=p4;
  84.   entity[numentities].p5=p5;
  85.   entity[numentities].p6=p6;
  86.  
  87.   numentities++;
  88. }
  89. 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){
  90.   entity[numentities].x=xp;
  91.   entity[numentities].y=yp;
  92.   entity[numentities].t=tp;
  93.   entity[numentities].p1=p1;
  94.   entity[numentities].p2=p2;
  95.   entity[numentities].p3=p3;
  96.   entity[numentities].p4=p4;
  97.   entity[numentities].p5=p5;
  98.   entity[numentities].p6=p6;
  99. }
  100.  
  101. void copyentity(int a, int b){
  102.   entity[a].x=entity[b].x;
  103.   entity[a].y=entity[b].y;
  104.   entity[a].t=entity[b].t;
  105.   entity[a].p1=entity[b].p1;
  106.   entity[a].p2=entity[b].p2;
  107.   entity[a].p3=entity[b].p3;
  108.   entity[a].p4=entity[b].p4;
  109.   entity[a].p5=entity[b].p5;
  110.   entity[a].p6=entity[b].p6;
  111. }
  112.  
  113. void removeentity(int t){
  114.   if(t==numentities-1){
  115.     numentities--;
  116.   }else{
  117.     for(int m=t;m<numentities;m++) copyentity(m,m+1);
  118.     numentities--;
  119.   }
  120. }
  121.  
  122. int entat(int xp, int yp){
  123.   for(int i=0; i<numentities; i++){
  124.     if(entity[i].x==xp && entity[i].y==yp) return i;
  125.   }
  126.   return -1;
  127. }
  128.  
  129.  
  130. bool entclear(int xp, int yp){
  131.   for(int i=0; i<numentities; i++){
  132.     if(entity[i].x==xp && entity[i].y==yp) return false;
  133.   }
  134.   return true;
  135. }
  136.  
  137. void savemapsimple(){
  138.   string s = "imports/"+currentarea+"/x"+its(mapx)+"y"+its(mapy)+".txt";
  139.   ofstream file;
  140.   file.open(s.c_str(), ios::trunc);
  141.  
  142.   for(int j=0; j<29; j++){
  143.     for(int i=0; i<40; i++){
  144.       file << mapcontents[i][j] << " ";
  145.     }
  146.     file << "\n";
  147.   }
  148.  
  149.   file << numentities << "\n";
  150.   for(int i=0; i<numentities; i++){
  151.     file << entity[i].x << " " << entity[i].y << " " << entity[i].t;
  152.     switch(entity[i].t){
  153.       case 1: case 2: //Enemy
  154.         file << " " << entity[i].p1 << " " << entity[i].p2
  155.              << " " << entity[i].p3 << " " << entity[i].p4
  156.              << " " << entity[i].p5 << " " << entity[i].p6;
  157.       break;
  158.       case 10: case 11: case 12: //Save point
  159.         file << " " << entity[i].p1; //p1: 0 hanging from roof
  160.       break;
  161.       default:
  162.       break;
  163.     }
  164.     file << "\n";
  165.   }
  166.  
  167.   file.close();
  168. }
  169.  
  170. void savemap(){
  171.   int ccount=0, scount=0;
  172.   savemapsimple();
  173.   string s = "maps/"+currentarea+"/x"+its(mapx)+"y"+its(mapy)+".txt";
  174.   ofstream file;
  175.   file.open(s.c_str(), ios::trunc);
  176.  
  177.   file << "case rn("<< its(mapx) << ","<< its(mapy) << "):\n";
  178.   file << "tmap = new Array();\n";
  179.  
  180.   for(int j=0; j<29; j++){
  181.     file << "tmap.push(\"";
  182.     for(int i=0; i<39; i++){
  183.       file << mapcontents[i][j] << ",";
  184.     }
  185.     file << mapcontents[39][j] << "\");\n";
  186.   }
  187.   //file << "fillcontent(tmap);\n";
  188.   if(numentities>0){
  189.     file << "\n";
  190.     for(int i=0; i<numentities; i++){
  191.       if(entity[i].t==11){
  192.         if(entity[i].x==0){
  193.           file << "obj.createentity(game, " << -8 << ", " << (entity[i].y*8)+4
  194.                << ", " << entity[i].t;
  195.         }else{
  196.           file << "obj.createentity(game, " << (entity[i].x*8) << ", " << (entity[i].y*8)+4
  197.                << ", " << entity[i].t;
  198.         }
  199.       }else if(entity[i].t==12){
  200.         if(entity[i].y==0){
  201.           file << "obj.createentity(game, " << (entity[i].x*8)+3 << ", " << -8
  202.                << ", " << entity[i].t;
  203.         }else{
  204.           file << "obj.createentity(game, " << (entity[i].x*8)+3 << ", " << (entity[i].y*8)
  205.                << ", " << entity[i].t;
  206.         }
  207.       }else if(entity[i].t==2 && entity[i].p1==4){
  208.         entity[i].t=3;
  209.       }else if(entity[i].t==2 && entity[i].p1==5){
  210.         entity[i].t=4;
  211.       }else if(entity[i].t==2 && entity[i].p1==6){
  212.         entity[i].t=4;
  213.       }else if(entity[i].t==2 && entity[i].p1==7){
  214.         entity[i].t=4;
  215.       }else if(entity[i].t==2 && entity[i].p1==8){
  216.         entity[i].t=4;
  217.       }else{
  218.         file << "obj.createentity(game, " << (entity[i].x*8) << ", " << (entity[i].y*8)
  219.              << ", " << entity[i].t;
  220.       }
  221.       switch(entity[i].t){
  222.         case 1: //Enemy
  223.           file << ", " << entity[i].p1 << ", " << entity[i].p2;
  224.           if(entity[i].p3==0 && entity[i].p4==0 && entity[i].p5==320 && entity[i].p6==240){
  225.             file << ");  // Enemy";
  226.           }else{
  227.             file << ", " << entity[i].p3 << ", " << entity[i].p4
  228.                  << ", " << entity[i].p5 << ", " << entity[i].p6
  229.                  << ");  // Enemy, bounded";
  230.           }
  231.         break;
  232.         case 2: //Moving platform
  233.           file << ", " << entity[i].p1 << ", " << entity[i].p2;
  234.           if(entity[i].p3==0 && entity[i].p4==0 && entity[i].p5==320 && entity[i].p6==240){
  235.             file << ");  // Platform";
  236.           }else{
  237.             file << ", " << entity[i].p3 << ", " << entity[i].p4
  238.                  << ", " << entity[i].p5 << ", " << entity[i].p6
  239.                  << ");  // Platform, bounded";
  240.           }
  241.         break;
  242.         case 3:
  243.           file << "obj.createentity(game, " << (entity[i].x*8) << ", " << (entity[i].y*8)
  244.                << ", 3);  //Disappearing Platform";
  245.           entity[i].t=2; //So that it doesn't disapear from the editor
  246.         break;
  247.         case 4:
  248.           if(entity[i].p1==5){
  249.             file << "obj.createentity(game, " << (entity[i].x*8) << ", " << (entity[i].y*8)
  250.                  << ", 2, 8, " << entity[i].p2 << ");  //Threadmill, >>>";
  251.           }else if(entity[i].p1==6){
  252.             file << "obj.createentity(game, " << (entity[i].x*8) << ", " << (entity[i].y*8)
  253.                  << ", 2, 9, " << entity[i].p2 << ");  //Threadmill, <<<";
  254.           }else if(entity[i].p1==7){
  255.             file << "obj.createentity(game, " << (entity[i].x*8) << ", " << (entity[i].y*8)
  256.                  << ", 2, 10, " << entity[i].p2 << ");  //Big Threadmill, >>>>>>";
  257.           }else if(entity[i].p1==8){
  258.             file << "obj.createentity(game, " << (entity[i].x*8) << ", " << (entity[i].y*8)
  259.                  << ", 2, 11, " << entity[i].p2 << ");  //Big Threadmill, <<<<<<";
  260.           }
  261.  
  262.           entity[i].t=2; //So that it doesn't disapear from the editor
  263.         break;
  264.         case 8: //coin
  265.           file << ", " << entity[i].p1 << ", coin+"<<ccount<<");  // (coins)";
  266.           ccount++;
  267.         break;
  268.         case 9: //shiny
  269.           file << ", " << entity[i].p1 << ", "<<ccount<<"+coin);  // (shiny trinket)";
  270.           ccount++;
  271.         break;
  272.         case 10: //Save point
  273.           if(currentarea=="otherlevel") mapy+=100;
  274.           if(currentarea=="lab") mapy+=200;
  275.           if(currentarea=="spacestation") mapy+=300;
  276.           if(currentarea=="spacestation2") mapy+=400;
  277.  
  278.  
  279.           file << ", " << entity[i].p1 << ", " << int(scount+((mapx+(mapy*100))*10)) << ");  // (savepoint)";
  280.           scount++;
  281.  
  282.           if(currentarea=="otherlevel") mapy-=100;
  283.           if(currentarea=="lab") mapy-=200;
  284.           if(currentarea=="spacestation") mapy-=300;
  285.           if(currentarea=="spacestation2") mapy-=400;
  286.         break;
  287.         case 11: //Horizontal
  288.           if(entity[i].x==0){
  289.             file << ", " << entity[i].p1+8 <<");  // (horizontal gravity line)";
  290.           }else{
  291.             file << ", " << entity[i].p1 <<");  // (horizontal gravity line)";
  292.           }
  293.         break;
  294.         case 12: //Vertical
  295.           if(entity[i].y==0){
  296.             file << ", " << entity[i].p1+8 <<");  // (vertical gravity line)";
  297.           }else{
  298.             file << ", " << entity[i].p1 <<");  // (vertical gravity line)";
  299.           }
  300.         break;
  301.         default:
  302.           file << ", behave, para);";
  303.         break;
  304.       }
  305.       file << "\n";
  306.     }
  307.   }
  308.  
  309.   //this bit only if in the lab:
  310.   temp=-1;
  311.   for(int j=0; j<29; j++){
  312.     for(int i=0; i<39; i++){
  313.       if(temp==-1){
  314.         if(mapcontents[i][j]==280) temp=0;
  315.         if(mapcontents[i][j]==283) temp=1;
  316.         if(mapcontents[i][j]==286) temp=2;
  317.         if(mapcontents[i][j]==289) temp=3;
  318.         if(mapcontents[i][j]==292) temp=4;
  319.         if(mapcontents[i][j]==295) temp=5;
  320.       }
  321.     }
  322.   }
  323.   //if(temp>=0){
  324.   //  file << "rcol="<<temp<<";\n";
  325.  // }
  326.   //
  327.  
  328.   file << "break;\n";
  329.  
  330.   file.close();
  331. }
  332.  
  333. bool loadmap(int x, int y){
  334.   int xp, yp, t, n;
  335.   int p1, p2, p3, p4, p5, p6;
  336.   string s = "imports/"+currentarea+"/x"+its(x)+"y"+its(y)+".txt";
  337.  
  338.   ifstream file;
  339.   file.open(s.c_str());
  340.   if(!file){
  341.     for(int j=1; j<28; j++){
  342.       for(int i=1; i<39; i++){
  343.         mapcontents[i][j]=0;
  344.       }
  345.     }
  346.     numentities=0;
  347.     return false;
  348.   }
  349.  
  350.   for(int j=0; j<29; j++){
  351.     for(int i=0; i<40; i++){
  352.       file >> mapcontents[i][j];
  353.     }
  354.   }
  355.  
  356.   file >> p;
  357.   numentities=0;
  358.   for(int i=0; i<p; i++){
  359.     file >> temp; file >> temp2; file >> temp3;
  360.     switch(temp3){
  361.       case 1: case 2: //Enemy, or platform
  362.         file >> p1; file >> p2; file >> p3; file >> p4; file >> p5; file >> p6;
  363.         addentity(temp,temp2,temp3,p1,p2,p3,p4,p5,p6);
  364.       break;
  365.       case 10: case 11: case 12: //Save point
  366.         file >> p1;
  367.         addentity(temp,temp2,temp3,p1);
  368.       break;
  369.       default:
  370.         addentity(temp,temp2,temp3);
  371.       break;
  372.     }
  373.   }
  374.  
  375.   file.close();
  376.   return true;
  377. }
  378.  
  379. void drawtile(int xp, int yp, int t){
  380.   blit(tiles[t], buffer, 0, 0, xp, yp, 16, 16);
  381. }
  382.  
  383. void print(BITMAP* bmp, int x, int y, string t, int r, int g, int b, bool c=false){
  384.   const char* txt=t.c_str();
  385.   if(c){x=160-(t.length()*4);}
  386.   textout_ex(bmp, font, txt, x-1, y, makecol(0,0,0), -1);
  387.   textout_ex(bmp, font, txt, x+1, y, makecol(0,0,0), -1);
  388.   textout_ex(bmp, font, txt, x, y-1, makecol(0,0,0), -1);
  389.   textout_ex(bmp, font, txt, x, y+1, makecol(0,0,0), -1);
  390.   textout_ex(bmp, font, txt, x, y, makecol(r,g,b), -1);
  391. }
  392.  
  393. void rprint(BITMAP* bmp, int x, int y, string t, int r, int g, int b, bool c=false){
  394.   const char* txt=t.c_str();
  395.   if(c){x=160-(t.length()*4);}
  396.   x=640-x-t.length()*8;
  397.   textout_ex(bmp, font, txt, x-1, y, makecol(0,0,0), -1);
  398.   textout_ex(bmp, font, txt, x+1, y, makecol(0,0,0), -1);
  399.   textout_ex(bmp, font, txt, x, y-1, makecol(0,0,0), -1);
  400.   textout_ex(bmp, font, txt, x, y+1, makecol(0,0,0), -1);
  401.   textout_ex(bmp, font, txt, x, y, makecol(r,g,b), -1);
  402. }
  403.  
  404.  
  405. void copymap(){
  406.   for(int j=0; j<29; j++){
  407.     for(int i=0; i<40; i++){
  408.        mapcopycontents[i][j]=mapcontents[i][j];
  409.     }
  410.   }
  411. }
  412.  
  413. void mapput(int x, int y, int t){
  414.   if(x>=0 && x<40 && y>=0 && y<29){
  415.     mapcontents[x][y]=t;
  416.   }
  417. }
  418.  
  419. int at(int x, int y){
  420.   if(x>=0 && x<40 && y>=0 && y<29){
  421.     return mapcopycontents[x][y];
  422.   }
  423.   if(x==-1) return at(x+1,y);
  424.   if(x==40) return at(x-1,y);
  425.   if(y==-1) return at(x,y+1);
  426.   if(y==29) return at(x,y-1);
  427.   return 0;
  428. }
  429.  
  430. int match(int x, int y, int t){
  431.   //Returns the first position match for a border
  432.   // 5 1 6
  433.   // 2 X 4
  434.   // 7 3 8
  435.  
  436.   if(at(x-1,y)!=t && at(x,y-1)!=t) return 10;
  437.   if(at(x+1,y)!=t && at(x,y-1)!=t) return 11;
  438.   if(at(x-1,y)!=t && at(x,y+1)!=t) return 12;
  439.   if(at(x+1,y)!=t && at(x,y+1)!=t) return 13;
  440.  
  441.   if(at(x,y-1)!=t) return 1;
  442.   if(at(x-1,y)!=t) return 2;
  443.   if(at(x,y+1)!=t) return 3;
  444.   if(at(x+1,y)!=t) return 4;
  445.   if(at(x-1,y-1)!=t) return 5;
  446.   if(at(x+1,y-1)!=t) return 6;
  447.   if(at(x-1,y+1)!=t) return 7;
  448.   if(at(x+1,y+1)!=t) return 8;
  449.   return 0;
  450. }
  451.  
  452. bool inbox(int x1, int y1, int x2, int y2, int xt, int yt){
  453.   if(xt>=x1 && xt<x2 && yt>=y1 && yt<y2) return true;
  454.   return false;
  455. }
  456.  
  457. int getbackground(){
  458.   //Return the background tile used on the map.
  459.   int x, y, t;
  460.  
  461.   for(int j=0; j<29; j++){
  462.     for(int i=0; i<40; i++){
  463.       t=at(i,j);
  464.       x=t%40;
  465.       y=(t-x)/40;
  466.       if(inbox(0,17,40,22,x,y)){
  467.         y=x%3;
  468.         x=(x-y)/3;
  469.         return x;
  470.       }
  471.     }
  472.   }
  473.  
  474.   return -1;
  475. }
  476.  
  477. int antiedge(int x, int y, int t){
  478.   //Opposite problem to edge: if t is in the range of any tile group, simplify
  479.   //it back to its basics.
  480.   //Simplist way is to turn it into a coordinate and check inbox ranges.
  481.   x=t%40;
  482.   y=(t-x)/40;
  483.   for(int i=0; i<13; i++){
  484.     if(inbox(0+(i*3),2,3+(i*3),7,x,y)) return 80+(i*3);
  485.     if(inbox(0+(i*3),7,3+(i*3),12,x,y)) return 280+(i*3);
  486.     if(inbox(0+(i*3),12,3+(i*3),17,x,y)) return 480+(i*3);
  487.     if(inbox(0+(i*3),17,3+(i*3),22,x,y)) return 680+(i*3);
  488.   }
  489.   return t;
  490. }
  491.  
  492. int edge(int x, int y, int t){
  493.   temp=1;
  494.   if(t>=880 && t<920){
  495.     temp=t-880;
  496.   }else if(t>=680 && t<720){
  497.     temp=t-680;
  498.   }else if(t>=480 && t<520){
  499.     temp=t-480;
  500.   }else if(t>=280 && t<320){
  501.     temp=t-280;
  502.   }else if(t>=80 && t<120){
  503.     temp=t-80;
  504.   }else{
  505.     return t;
  506.   }
  507.  
  508.   if(temp%3==0){
  509.     //we have a candidate for edginess!
  510.     switch(match(x,y,t)){
  511.       case 10: return t+80; break;
  512.       case 11: return t+82; break;
  513.       case 12: return t+160; break;
  514.       case 13: return t+162; break;
  515.       case 1: return t+81; break;
  516.       case 2: return t+120; break;
  517.       case 3: return t+161; break;
  518.       case 4: return t+122; break;
  519.       case 5: return t+42; break;
  520.       case 6: return t+41; break;
  521.       case 7: return t+2; break;
  522.       case 8: return t+1; break;
  523.       case 0: default: return t; break;
  524.     }
  525.   }
  526.  
  527.   return t;
  528. }
  529.  
  530. void change_fullscreen(){
  531.   destroy_bitmap(page[0]);
  532.   destroy_bitmap(page[1]);
  533.   destroy_bitmap(page[2]);
  534.   set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 640, 480, 0, 0);
  535.   clear_bitmap(screen);
  536.  
  537.  
  538.   page[0]=create_video_bitmap(640, 480);
  539.   page[1]=create_video_bitmap(640, 480);
  540.   page[2]=create_video_bitmap(640, 480);
  541. }
  542.  
  543. void change_windowed(){
  544.   destroy_bitmap(page[0]);
  545.   destroy_bitmap(page[1]);
  546.   destroy_bitmap(page[2]);
  547.  
  548.   set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
  549.   clear_bitmap(screen);
  550.  
  551.  
  552.   page[0]=create_video_bitmap(640, 480);
  553.   page[1]=create_video_bitmap(640, 480);
  554.   page[2]=create_video_bitmap(640, 480);
  555. }
  556.  
  557. int main(){
  558.   test=false; teststring="TEST = True";
  559.   int state=0, gt=0;
  560.   int tileset=0;
  561.   savednote=0; numentities=0; paraadjustdelay=0;
  562.   currentarea="spacestation2";
  563.   //currentarea="lab";
  564.   //currentarea="otherlevel";
  565.   //Setup Allegro
  566.   allegro_init();
  567.   //Setup input
  568.   install_keyboard();
  569.   install_mouse();
  570.   show_os_cursor(MOUSE_CURSOR_ARROW);
  571.  
  572.   //Setup timer
  573.   install_timer();
  574.   LOCK_VARIABLE(speed_counter);
  575.   LOCK_FUNCTION(increment_speed_counter);
  576.   install_int_ex(increment_speed_counter, BPS_TO_TIMER(60));
  577.  
  578.   //Setup graphics8
  579.   set_color_depth(32);
  580.   set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
  581.   register_png_file_type();
  582.   int currentpage=0;
  583.   fullscreen=false;
  584.  
  585.   if(tileset==0){
  586.     buffer=load_png("../../engine/current/data/graphics/tiles.png", dummypal);
  587.   }else if(tileset==1){
  588.     buffer=load_png("../../engine/current/data/graphics/tiles2.png", dummypal);
  589.   }
  590.   for(int y=0;y<30;y++){
  591.     for(int x=0;x<40;x++){
  592.       tiles[x+(y*40)] = create_bitmap(8, 8);
  593.       rectfill(tiles[x+(y*40)], 0, 0, 8, 8, makecol(16,16,16));
  594.       blit(buffer, tiles[x+(y*40)], x*8, y*8, 0, 0, 8,8);
  595.     }
  596.   }
  597.   destroy_bitmap(buffer);
  598.  
  599.   buffer=create_bitmap(320,240);
  600.   biggerbuffer=create_bitmap(640,480);
  601.   page[0]=create_video_bitmap(640, 480);
  602.   page[1]=create_video_bitmap(640, 480);
  603.   page[2]=create_video_bitmap(640, 480);
  604.   currentpage=0;
  605.  
  606.   //Setup sound
  607.   set_volume_per_voice(0);
  608.   if (install_sound(DIGI_AUTODETECT, MIDI_NONE, 0) < 0) {
  609.     set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
  610.     allegro_message("Error installing sound.\n");
  611.   }
  612.  
  613.   //Init map
  614.   //Load last?
  615.   //Blank
  616.   mapx=56; mapy=43;
  617.   if(!loadmap(mapx, mapy)){
  618.     for(int j=0; j<29; j++){
  619.       for(int i=0; i<40; i++){
  620.         mapcontents[i][j]=0;
  621.       }
  622.     }
  623.   }
  624.   xp=0; yp=0; ctile=0;
  625.   tileselectdelay=0;
  626.   reversekey=0;
  627.  
  628.  //Starting main loop:
  629.   while(!key[KEY_ESC]){
  630.     xp=mouse_x/16;
  631.     yp=mouse_y/16;
  632.     //Render
  633.     if(tileset==0){
  634.       clear_to_color(buffer, makecol(0,0,0));
  635.     }else{
  636.       clear_to_color(buffer, makecol(32,32,32));
  637.     }
  638.  
  639.     for(int j=0; j<29; j++){
  640.       for(int i=0; i<40; i++){
  641.         rect(buffer, i*8, j*8, (i*8)+7, (j*8)+7, makecol(16,16,16)); //a simple grid
  642.         if(i%4==0) rect(buffer, i*8, j*8, (i*8)+7, (j*8)+7, makecol(32,32,32));
  643.         if(j%4==0) rect(buffer, i*8, j*8, (i*8)+7, (j*8)+7, makecol(32,32,32));
  644.  
  645.         //Minor guides
  646.         if(i==9) rect(buffer, i*8, j*8, (i*8)+7, (j*8)+7, makecol(48,48,48));
  647.         if(i==30) rect(buffer, i*8, j*8, (i*8)+7, (j*8)+7, makecol(48,48,48));
  648.         if(j==6 || j==7) rect(buffer, i*8, j*8, (i*8)+7, (j*8)+7, makecol(48,48,48));
  649.         if(j==21 || j==22) rect(buffer, i*8, j*8, (i*8)+7, (j*8)+7, makecol(48,48,48));
  650.  
  651.         //Major guides
  652.         if(i==20 || i==19) rect(buffer, i*8, j*8, (i*8)+7, (j*8)+7, makecol(64,64,64));
  653.         if(j==14) rect(buffer, i*8, j*8, (i*8)+7, (j*8)+7, makecol(64,64,64));
  654.       }
  655.     }
  656.  
  657.     for(int j=0; j<29; j++){
  658.       for(int i=0; i<40; i++){
  659.         if(mapcontents[i][j]>0) drawtile(i*8, j*8, mapcontents[i][j]);
  660.       }
  661.     }
  662.  
  663.  
  664.     //Draw entities
  665.     temp=entat(xp,yp);
  666.     for(int i=0; i<numentities; i++){
  667.       switch(entity[i].t){
  668.         case 1: //Enemy
  669.           teststring="E";
  670.           if(entity[i].p1==0) teststring+="v";
  671.           if(entity[i].p1==1) teststring+="^";
  672.           if(entity[i].p1==2) teststring+="<";
  673.           if(entity[i].p1==3) teststring+=">";
  674.  
  675.           textout_ex(buffer, font, teststring.c_str(), (entity[i].x*8),(entity[i].y*8)+4,
  676.                        makecol(255,255,255), -1);
  677.           if(i==temp){
  678.             teststring=its(entity[i].p2);
  679.             textout_ex(buffer, font, teststring.c_str(), (entity[i].x*8)+4,(entity[i].y*8)+17,
  680.                          makecol(255,255,255), -1);
  681.  
  682.             rect(buffer,entity[i].x*8,entity[i].y*8,(entity[i].x*8)+15,(entity[i].y*8)+15,
  683.                  makecol(255,0,0));
  684.             rect(buffer,entity[i].p3,entity[i].p4,entity[i].p5-1,entity[i].p6-1,
  685.                  makecol(255,128,0));
  686.           }else{
  687.             rect(buffer,entity[i].x*8,entity[i].y*8,(entity[i].x*8)+15,(entity[i].y*8)+15,
  688.                  makecol(255,164,164));
  689.           }
  690.         break;
  691.         case 2: //Platform
  692.           teststring="P ";
  693.           if(entity[i].p1==0) teststring+="v";
  694.           if(entity[i].p1==1) teststring+="^";
  695.           if(entity[i].p1==2) teststring+="<";
  696.           if(entity[i].p1==3) teststring+=">";
  697.           if(entity[i].p1==4) teststring+="=";
  698.           if(entity[i].p1==5) teststring=">>>";
  699.           if(entity[i].p1==6) teststring="<<<";
  700.           if(entity[i].p1==7) teststring="> > > >";
  701.           if(entity[i].p1==8) teststring="< < < <";
  702.  
  703.           textout_ex(buffer, font, teststring.c_str(), (entity[i].x*8)+4,(entity[i].y*8),
  704.                        makecol(255,255,255), -1);
  705.           if(i==temp){
  706.             teststring=its(entity[i].p2);
  707.             textout_ex(buffer, font, teststring.c_str(), (entity[i].x*8)+4,(entity[i].y*8)+9,
  708.                          makecol(255,255,255), -1);
  709.  
  710.             if(entity[i].p1<7){
  711.               rect(buffer,entity[i].x*8,entity[i].y*8,(entity[i].x*8)+31,(entity[i].y*8)+7,
  712.                    makecol(0,0,255));
  713.               rect(buffer,entity[i].p3,entity[i].p4,entity[i].p5-1,entity[i].p6-1,
  714.                    makecol(255,128,0));
  715.             }else{
  716.               rect(buffer,entity[i].x*8,entity[i].y*8,(entity[i].x*8)+31+32,(entity[i].y*8)+7,
  717.                    makecol(0,0,255));
  718.               rect(buffer,entity[i].p3,entity[i].p4,entity[i].p5-1,entity[i].p6-1,
  719.                    makecol(255,128,0));
  720.             }
  721.           }else{
  722.  
  723.             if(entity[i].p1<7){
  724.               rect(buffer,entity[i].x*8,entity[i].y*8,(entity[i].x*8)+31,(entity[i].y*8)+7,
  725.                  makecol(164,164,255));
  726.             }else{
  727.               rect(buffer,entity[i].x*8,entity[i].y*8,(entity[i].x*8)+31+32,(entity[i].y*8)+7,
  728.                  makecol(164,164,255));
  729.             }
  730.           }
  731.         break;
  732.         case 8: //Small Pickup
  733.           rect(buffer,entity[i].x*8,entity[i].y*8,(entity[i].x*8)+7,(entity[i].y*8)+7,
  734.                makecol(164,164,255));
  735.         break;
  736.         case 9: //Big Pickup
  737.           rect(buffer,entity[i].x*8,entity[i].y*8,(entity[i].x*8)+15,(entity[i].y*8)+15,
  738.                makecol(164,164,255));
  739.         break;
  740.         case 10: //Savepoint
  741.           if(entity[i].p1==0){
  742.             //on the roof!
  743.             teststring="r";
  744.             textout_ex(buffer, font, teststring.c_str(), (entity[i].x*8)+4,entity[i].y*8,
  745.                        makecol(255,255,255), -1);
  746.             teststring="v";
  747.             textout_ex(buffer, font, teststring.c_str(), (entity[i].x*8)+4,(entity[i].y*8)+8,
  748.                        makecol(255,255,255), -1);
  749.           }else{
  750.             //on the floor!
  751.             teststring="^";
  752.             textout_ex(buffer, font, teststring.c_str(), (entity[i].x*8)+4,entity[i].y*8,
  753.                        makecol(255,255,255), -1);
  754.             teststring="f";
  755.             textout_ex(buffer, font, teststring.c_str(), (entity[i].x*8)+4,(entity[i].y*8)+8,
  756.                        makecol(255,255,255), -1);
  757.           }
  758.           rect(buffer,entity[i].x*8,entity[i].y*8,(entity[i].x*8)+15,(entity[i].y*8)+15,
  759.                makecol(164,255,164));
  760.         break;
  761.         case 11:
  762.           if(i==temp){
  763.             rect(buffer,entity[i].x*8,entity[i].y*8,(entity[i].x*8)+entity[i].p1-1,(entity[i].y*8)+7,
  764.                  makecol(0,255,0));
  765.             line(buffer,entity[i].x*8,(entity[i].y*8)+3,(entity[i].x*8)+entity[i].p1-1,(entity[i].y*8)+3,
  766.                  makecol(0,255,0));
  767.             line(buffer,entity[i].x*8,(entity[i].y*8)+4,(entity[i].x*8)+entity[i].p1-1,(entity[i].y*8)+4,
  768.                  makecol(0,255,0));
  769.           }else{
  770.             rect(buffer,entity[i].x*8,entity[i].y*8,(entity[i].x*8)+entity[i].p1-1,(entity[i].y*8)+7,
  771.                  makecol(164,255,164));
  772.             line(buffer,entity[i].x*8,(entity[i].y*8)+3,(entity[i].x*8)+entity[i].p1-1,(entity[i].y*8)+3,
  773.                  makecol(164,255,164));
  774.             line(buffer,entity[i].x*8,(entity[i].y*8)+4,(entity[i].x*8)+entity[i].p1-1,(entity[i].y*8)+4,
  775.                  makecol(164,255,164));
  776.           }
  777.         break;
  778.         case 12: //vertical
  779.           if(i==temp){
  780.             rect(buffer,entity[i].x*8,entity[i].y*8,(entity[i].x*8)+7,(entity[i].y*8)-1+entity[i].p1,
  781.                  makecol(0,255,0));
  782.             line(buffer,(entity[i].x*8)+3,(entity[i].y*8),(entity[i].x*8)+3,(entity[i].y*8)-1+entity[i].p1,
  783.                  makecol(0,255,0));
  784.             line(buffer,(entity[i].x*8)+4,(entity[i].y*8),(entity[i].x*8)+4,(entity[i].y*8)-1+entity[i].p1,
  785.                  makecol(0,255,0));
  786.  
  787.           }else{
  788.             rect(buffer,entity[i].x*8,entity[i].y*8,(entity[i].x*8)+7,(entity[i].y*8)-1+entity[i].p1,
  789.                  makecol(164,255,164));
  790.             line(buffer,(entity[i].x*8)+3,(entity[i].y*8),(entity[i].x*8)+3,(entity[i].y*8)-1+entity[i].p1,
  791.                  makecol(164,255,164));
  792.             line(buffer,(entity[i].x*8)+4,(entity[i].y*8),(entity[i].x*8)+4,(entity[i].y*8)-1+entity[i].p1,
  793.                  makecol(164,255,164));
  794.           }
  795.         break;
  796.       }
  797.     }
  798.     //GUI
  799.     rect(buffer, 4,230,13,239,makecol(128,128,128));
  800.     drawtile(5, 231, ctile);
  801.     print(buffer, 24, 231, "Tile " + its(ctile), 255,255,255);
  802.     tempstring="("+its(xp)+","+its(yp)+") ["+its(mapx)+","+its(mapy)+"]";
  803.     print(buffer, 200, 231, tempstring, 196,196,255);
  804.  
  805.     if(savednote>0){
  806.       if(savednote>70){
  807.         temp=200-((90-savednote)*10);
  808.         print(buffer, 24, 115, "[Map Saved]", 255-temp,255-temp,255-temp, true);
  809.       }else if(savednote<20){
  810.         temp=(20-savednote)*10;
  811.         print(buffer, 24, 115, "[Map Saved]", 255-temp,255-temp,255-temp, true);
  812.       }else{
  813.         print(buffer, 24, 115, "[Map Saved]", 255,255,255, true);
  814.       }
  815.  
  816.       savednote--;
  817.     }
  818.  
  819.  
  820.     rect(buffer, (xp*8), (yp*8), (xp*8)+7, (yp*8)+7, makecol(255,128,128));
  821.  
  822.     if(test) print(buffer, 5, 5, teststring, 255,255,255);
  823.  
  824.     //Instructions
  825.     //print(buffer, 5, 5, "Simple Tool framework", 255,255,255);
  826.  
  827.     stretch_blit(buffer, biggerbuffer, 0, 0, 320, 240, 0, 0, 640, 480);
  828.     rprint(biggerbuffer, 5, 5, "Current Area: [" + currentarea+"]", 128,128, 255);
  829.     rprint(biggerbuffer, 5, 20, "R[<<<] T[>>>] Y[Plat] U[Coins] I[Shiny] O[Enemy] P[Save]", 196,196,196);
  830.     rprint(biggerbuffer, 5, 30, "Q[Edge] W[AntiEdge] A+[Move] S+[Invert] F[Fill]", 196,196,196);
  831.  
  832.     rprint(biggerbuffer, 5, 20, "R      T      Y       U        I        O        P      ", 128,128, 255);
  833.     rprint(biggerbuffer, 5, 30, "Q       W           A+       S+         F      ", 128,128, 255);
  834.  
  835.     //print(biggerbuffer, 5, 5, its(numentities), 255,255,255);
  836.     //for(int i=0; i<numentities; i++){
  837.     //  tempstring="entity["+its(i)+"]=("+its(entity[i].x)+","+its(entity[i].y)+","+its(entity[i].t)+")";
  838.     //  print(biggerbuffer, 5, 15+(i*10), tempstring, 255,255,255);
  839.    // }
  840.  
  841.     blit(biggerbuffer, page[currentpage], 0, 0, 0, 0, 640, 480);
  842.     //Instructions, more info
  843.     show_video_bitmap(page[currentpage]);
  844.     currentpage = (currentpage+1)%3;
  845.     //Input
  846.     if(mouse_b & 1){
  847.       if(yp<29){
  848.         //Left click
  849.         if(key[KEY_Z]){
  850.           mapput(xp-1, yp-1, ctile);
  851.           mapput(xp,   yp-1, ctile);
  852.           mapput(xp+1, yp-1, ctile);
  853.           mapput(xp-1, yp,   ctile);
  854.           mapput(xp,   yp,   ctile);
  855.           mapput(xp+1, yp,   ctile);
  856.           mapput(xp-1, yp+1, ctile);
  857.           mapput(xp,   yp+1, ctile);
  858.           mapput(xp+1, yp+1, ctile);
  859.         }else{
  860.           mapput(xp, yp, ctile);
  861.         }
  862.       }
  863.     }
  864.     if(mouse_b & 2){
  865.       //Right click
  866.       if(yp<29){
  867.         ctile=mapcontents[xp][yp];
  868.       }
  869.       for(int i=0; i<numentities; i++){
  870.         if(entity[i].x==xp && entity[i].y==yp){
  871.           removeentity(i);
  872.         }
  873.       }
  874.     }
  875.  
  876.     if(tileselectdelay<=0){
  877.       if(key[KEY_COMMA]){
  878.         ctile--;
  879.         tileselectdelay=10;
  880.       }
  881.       if(key[KEY_STOP]){
  882.         ctile++;
  883.         tileselectdelay=10;
  884.       }
  885.       if(key[KEY_CLOSEBRACE]){
  886.         ctile+=40;
  887.         tileselectdelay=10;
  888.       }
  889.       if(key[KEY_OPENBRACE]){
  890.         ctile-=40;
  891.         tileselectdelay=10;
  892.       }
  893.       if(key[KEY_A]){
  894.         if(key[KEY_UP])   { mapy--; loadmap(mapx,mapy); tileselectdelay=10; }
  895.         if(key[KEY_DOWN]) { mapy++; loadmap(mapx,mapy); tileselectdelay=10; }
  896.         if(key[KEY_LEFT]) { mapx--; loadmap(mapx,mapy); tileselectdelay=10; }
  897.         if(key[KEY_RIGHT]){ mapx++; loadmap(mapx,mapy); tileselectdelay=10; }
  898.       }
  899.     }else{
  900.       tileselectdelay--;
  901.     }
  902.     if(ctile<0) ctile+=1200;
  903.     if(ctile>=1200) ctile-=1200;
  904.  
  905.     //Shortcuts
  906.     if(tileselectdelay<=0){
  907.       tileselectdelay=20;
  908.       if(key[KEY_B]){ctile=680;} //Backgrounds
  909.       else if(key[KEY_V]){ctile=80;} //Foregrounds
  910.       else if(key[KEY_1]){p=80;if(ctile==200+p){ctile=400+p;}else if(ctile==p){ctile=200+p;}else{ctile=p;}}
  911.       else if(key[KEY_2]){p=83;if(ctile==200+p){ctile=400+p;}else if(ctile==p){ctile=200+p;}else{ctile=p;}}
  912.       else if(key[KEY_3]){p=86;if(ctile==200+p){ctile=400+p;}else if(ctile==p){ctile=200+p;}else{ctile=p;}}
  913.       else if(key[KEY_4]){p=89;if(ctile==200+p){ctile=400+p;}else if(ctile==p){ctile=200+p;}else{ctile=p;}}
  914.       else if(key[KEY_5]){p=92;if(ctile==200+p){ctile=400+p;}else if(ctile==p){ctile=200+p;}else{ctile=p;}}
  915.       else if(key[KEY_6]){p=95;if(ctile==200+p){ctile=400+p;}else if(ctile==p){ctile=200+p;}else{ctile=p;}}
  916.       else if(key[KEY_7]){p=98;if(ctile==200+p){ctile=400+p;}else if(ctile==p){ctile=200+p;}else{ctile=p;}}
  917.       else if(key[KEY_8]){p=101;if(ctile==200+p){ctile=400+p;}else if(ctile==p){ctile=200+p;}else{ctile=p;}}
  918.       else if(key[KEY_9]){p=104;if(ctile==200+p){ctile=400+p;}else if(ctile==p){ctile=200+p;}else{ctile=p;}}
  919.       else if(key[KEY_0]){p=107;if(ctile==200+p){ctile=400+p;}else if(ctile==p){ctile=200+p;}else{ctile=p;}}
  920.       else if(key[KEY_MINUS]){p=110;if(ctile==200+p){ctile=400+p;}else if(ctile==p){ctile=200+p;}else{ctile=p;}}
  921.       else if(key[KEY_EQUALS]){p=113;if(ctile==200+p){ctile=400+p;}else if(ctile==p){ctile=200+p;}else{ctile=p;}}
  922.       else if(key[KEY_BACKSPACE]){p=116;if(ctile==200+p){ctile=400+p;}else if(ctile==p){ctile=200+p;}else{ctile=p;}}
  923.       else{
  924.         tileselectdelay=0;
  925.       }
  926.     }else{
  927.       tileselectdelay--;
  928.     }
  929.  
  930.     if(key[KEY_H]){
  931.       //Flip background
  932.       copymap();
  933.       temp=getbackground();
  934.       if(temp>-1){
  935.         temp2=temp+1;
  936.         if(temp2>=7) temp2=0;
  937.         temp=680+(temp*3);
  938.         temp2=680+(temp2*3);
  939.         for(int j=0; j<29; j++){
  940.           for(int i=0; i<40; i++){
  941.             if(mapcontents[i][j]==temp) mapcontents[i][j]=temp2;
  942.           }
  943.         }
  944.         while(key[KEY_H]);
  945.       }
  946.     }
  947.  
  948.     if(key[KEY_F8]){
  949.       savemap();
  950.       while(key[KEY_F8]);
  951.       savednote=90;
  952.     }
  953.  
  954.     if(key[KEY_F7]){
  955.       loadmap(mapx,mapy);
  956.       while(key[KEY_F7]);
  957.     }
  958.  
  959.  
  960.     if(key[KEY_F]){
  961.       copymap();
  962.       temp=at(xp,yp);
  963.       for(int j=0; j<29; j++){
  964.         for(int i=0; i<40; i++){
  965.           if(mapcontents[i][j]==temp) mapcontents[i][j]=ctile;
  966.         }
  967.       }
  968.     }
  969.  
  970.     if(key[KEY_G]){
  971.       for(int j=0; j<29; j++){
  972.         for(int i=0; i<40; i++){
  973.           mapcontents[i][j]=ctile;
  974.         }
  975.       }
  976.     }
  977.  
  978.  
  979.  
  980.     if(key[KEY_Q]){
  981.       //Autoedge! Experimental :O
  982.       copymap();
  983.       for(int j=0; j<29; j++){
  984.         for(int i=0; i<40; i++){
  985.           temp=mapcopycontents[i][j];
  986.           mapcontents[i][j]=edge(i, j, temp);
  987.         }
  988.       }
  989.       while(key[KEY_Q]);
  990.     }
  991.  
  992.     if(key[KEY_W]){
  993.       //Antiedge!
  994.       copymap();
  995.       for(int j=0; j<29; j++){
  996.         for(int i=0; i<40; i++){
  997.           temp=mapcopycontents[i][j];
  998.           mapcontents[i][j]=antiedge(i, j, temp);
  999.         }
  1000.       }
  1001.       while(key[KEY_W]);
  1002.     }
  1003.  
  1004.     if(reversekey<=0){
  1005.       if(key[KEY_S] && (key[KEY_LEFT]||key[KEY_RIGHT])){
  1006.         copymap();
  1007.         for(int j=0; j<29; j++){
  1008.           for(int i=0; i<40; i++){
  1009.             mapcontents[i][j]=mapcopycontents[39-i][j];
  1010.           }
  1011.         }
  1012.         reversekey=10;
  1013.       }
  1014.       if(key[KEY_S] && (key[KEY_UP]||key[KEY_DOWN])){
  1015.         copymap();
  1016.         for(int j=0; j<29; j++){
  1017.           for(int i=0; i<40; i++){
  1018.             mapcontents[i][j]=mapcopycontents[i][28-j];
  1019.           }
  1020.         }
  1021.         reversekey=10;
  1022.       }
  1023.     }else{
  1024.       reversekey--;
  1025.     }
  1026.  
  1027.     if(key[KEY_F4]){
  1028.       if(fullscreen){
  1029.         change_windowed();
  1030.         fullscreen=false;
  1031.       }else{
  1032.         change_fullscreen();
  1033.         fullscreen=true;
  1034.       }
  1035.       while(key[KEY_F4]);
  1036.     }
  1037.  
  1038.     if(entclear(xp,yp)){
  1039.       if(key[KEY_R]){ addentity(xp,yp,2,6,4); while(key[KEY_R]); }
  1040.       if(key[KEY_T]){ addentity(xp,yp,2,5,4); while(key[KEY_T]); }
  1041.  
  1042.       if(key[KEY_Y]){ addentity(xp,yp,2); while(key[KEY_Y]); }
  1043.       if(key[KEY_U]) addentity(xp,yp,8);
  1044.       if(key[KEY_I]) addentity(xp,yp,9);
  1045.       if(key[KEY_O]){ addentity(xp,yp,1); while(key[KEY_O]); }
  1046.       if(key[KEY_P]){ addentity(xp,yp,10); while(key[KEY_P]); }
  1047.     }else{
  1048.       temp=entat(xp,yp);
  1049.       if(temp>-1){
  1050.         if(key[KEY_O]){
  1051.           if(entity[temp].t==1){
  1052.             entity[temp].p1++;
  1053.             if(entity[temp].p1>=4) entity[temp].p1=0;
  1054.             while(key[KEY_O]);
  1055.           }
  1056.         }
  1057.  
  1058.         if(key[KEY_T]){
  1059.           if(entity[temp].t==2){
  1060.             if(entity[temp].p1==5){
  1061.               entity[temp].p1=7;
  1062.             }else if(entity[temp].p1==7){
  1063.               entity[temp].p1=5;
  1064.             }
  1065.             while(key[KEY_T]);
  1066.           }
  1067.         }
  1068.  
  1069.         if(key[KEY_R]){
  1070.           if(entity[temp].t==2){
  1071.             if(entity[temp].p1==6){
  1072.               entity[temp].p1=8;
  1073.             }else if(entity[temp].p1==8){
  1074.               entity[temp].p1=6;
  1075.             }
  1076.             while(key[KEY_R]);
  1077.           }
  1078.         }
  1079.  
  1080.  
  1081.         if(key[KEY_Y]){
  1082.           if(entity[temp].t==2){
  1083.             entity[temp].p1++;
  1084.             if(entity[temp].p1>=9) entity[temp].p1=0;
  1085.             while(key[KEY_Y]);
  1086.           }
  1087.         }
  1088.  
  1089.         if(key[KEY_P]){
  1090.           if(entity[temp].t==10){
  1091.             if(entity[temp].p1==0){
  1092.               entity[temp].p1=1;
  1093.             }else{
  1094.               entity[temp].p1=0;
  1095.             }
  1096.             while(key[KEY_P]);
  1097.           }
  1098.         }
  1099.  
  1100.         if(entity[temp].t==11 || entity[temp].t==12){
  1101.           if(paraadjustdelay<=0){
  1102.             if(key[KEY_J]){
  1103.               if(key[KEY_LEFT]) { entity[temp].p1-=8; paraadjustdelay=4; }
  1104.               if(key[KEY_RIGHT]){ entity[temp].p1+=8; paraadjustdelay=4; }
  1105.               if(key[KEY_UP]) { entity[temp].p1-=8; paraadjustdelay=4; }
  1106.               if(key[KEY_DOWN]){ entity[temp].p1+=8; paraadjustdelay=4; }
  1107.               if(entity[temp].p1<=0) entity[temp].p1=0;
  1108.             }
  1109.           }else{
  1110.             paraadjustdelay--;
  1111.           }
  1112.         }
  1113.  
  1114.         if(entity[temp].t==1 || entity[temp].t==2){
  1115.           if(paraadjustdelay<=0){
  1116.             if(key[KEY_J]){
  1117.               if(key[KEY_LEFT]) { entity[temp].p2--; paraadjustdelay=4; }
  1118.               if(key[KEY_RIGHT]){ entity[temp].p2++; paraadjustdelay=4; }
  1119.               if(entity[temp].p2<=0) entity[temp].p2=0;
  1120.             }
  1121.             if(key[KEY_K]){
  1122.               if(key[KEY_LEFT]) { entity[temp].p3-=8; paraadjustdelay=4; }
  1123.               if(key[KEY_RIGHT]){ entity[temp].p3+=8; paraadjustdelay=4; }
  1124.               if(key[KEY_UP]) { entity[temp].p4-=8; paraadjustdelay=4; }
  1125.               if(key[KEY_DOWN]){ entity[temp].p4+=8; paraadjustdelay=4; }
  1126.             }
  1127.             if(key[KEY_L]){
  1128.               if(key[KEY_LEFT]) { entity[temp].p5-=8; paraadjustdelay=4; }
  1129.               if(key[KEY_RIGHT]){ entity[temp].p5+=8; paraadjustdelay=4; }
  1130.               if(key[KEY_UP]) { entity[temp].p6-=8; paraadjustdelay=4; }
  1131.               if(key[KEY_DOWN]){ entity[temp].p6+=8; paraadjustdelay=4; }
  1132.             }
  1133.           }else{
  1134.             paraadjustdelay--;
  1135.           }
  1136.         }
  1137.       }
  1138.     }
  1139.  
  1140.     //if(key[KEY_BACKSPACE]){
  1141.     //  numentities=0;
  1142.     //}
  1143.  
  1144.     /*if(key[KEY_F1]) currentarea="otherlevel";
  1145.     if(key[KEY_F2]) currentarea="spacestation";
  1146.     if(key[KEY_F3]) currentarea="lab";*/
  1147.  
  1148.     //Logic
  1149.     gt++;
  1150.     while(speed_counter<1) rest(1); speed_counter = 0;
  1151.   }
  1152.  
  1153.     return 0;
  1154. }
  1155. END_OF_MAIN()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement