Author Topic: [Entry] EI0 Map editor + OSlib map loading source code  (Read 6405 times)

0 Members and 1 Guest are viewing this topic.

Offline smealum

  • Neo-Newbie
  • Sr. Member
  • *
  • Posts: 265
    • Smea's DevBlog
[Entry] EI0 Map editor + OSlib map loading source code
« on: August 20, 2006, 01:12:30 AM »
Hi !
This entry is a map editor for Earth Invaders 0 and for YOUR future PSP games ! :)
It includes a source code that permits you to load maps from external files. This will allow your players to create their own maps for your games, just like i did with EI 0.

Here's the source code to load maps (i use OSlib) :

Quote
while (!osl_quit)
   {
   oslStartDrawing();
   oslReadKeys();
   oslDrawFillRect(0,0,480,272,RGB(255,255,255));

   oslPrintf_xy(20, 20, "Map name : %s\n\n Up/down : Change map\nCross : Select map",maps[choix].name);
   if(osl_keys->pressed.up && choix < nbmaps-1)choix++;
   else if(osl_keys->pressed.down && choix > 2)choix--;
   else if(osl_keys->pressed.cross)break;
   oslEndDrawing();
   oslSyncFrame();
   }
   strcpy(mapname,maps[choix].name);
   while (!osl_quit)
   {
   if(chdir(mapname)!=0)oslMessageBox("Critiqual error. Press Triangle to quit.", "Error", oslMake3Buttons(OSL_KEY_TRIANGLE,OSL_MB_QUIT,0,0,0,0));
   fond = oslLoadImageFile("fond.png", OSL_IN_RAM, OSL_PF_5551);
   maptiles = LoadTileset("tiles.png");
   if(!fond || !maptiles)oslMessageBox("Critiqual error. Press Triangle to quit.", "Error", oslMake3Buttons(OSL_KEY_TRIANGLE,OSL_MB_QUIT,0,0,0,0));
    col=fopen("col","r");
   bg=fopen("bg","r");
   events=fopen("events","r");
   if(!bg || !col || !events)oslMessageBox("Critiqual error. Press Triangle to quit.", "Error", oslMake3Buttons(OSL_KEY_TRIANGLE,OSL_MB_QUIT,0,0,0,0));
   fscanf(col,"%ld;%ld",&map1.sizey,&map1.sizex);
   for(i=0;i<map1.sizey;i++)
   {
   for(j=0;j<map1.sizex;j++)
   {
   fscanf(col,"%hd,",&map1_map(i,j));
   fscanf(bg,"%hd,",&map1_map1(i,j));
   fscanf(events,"%hd,",&map1_map2(i,j));
   }
   }
   fclose(col);
   fclose(bg);
   fclose(events);
map1_map tables are shorts.
Also, here are the defines i use :
#define map1_map(i,j) map1_map[j]
#define map1_map1(i,j) map1_map1[j]
#define map1_map2(i,j) map1_map2[j]

Unfortunetaly, the last version of EI 0 is very buggy, so some maps might not work well with it...

Here are the controls :
D-PAD : Move the pointer
X : Put tile
/\ : Delete tile
R / L : Change tile
Start : Save

The map will always be saved to the output folder.

Offline wraggster

  • Sr. Member
  • ****
  • Posts: 261
    • DCEmu Homebrew Network
Re: [Entry] EI0 Map editor + OSlib map loading source code
« Reply #1 on: August 20, 2006, 01:23:05 AM »
this will be excellent for the PSP game modders at my site


Webmaster of DCEmu

The Worlds Only Homebrew and Gaming Network Covering All Consoles.