Hello, I have been searching for a tutorial on tile engines in C/C++, but I cannot seem to find any. Does anyone know where I can find one? Or at least the concept of writing one? I am using Borland C++ 5.02. Thanks!
Hello, I have been searching for a tutorial on tile engines in C/C++, but I cannot seem to find any. Does anyone know where I can find one? Or at least the concept of writing one? I am using Borland C++ 5.02. Thanks!
What are you using as a graphics lib? Often an appropriate tile engine tutorial will be available for specific graphics library.
Allegro precompiled Installer for Dev-C++, MSVC, and Borland: http://galileo.spaceports.com/~springs/
using the built in graphics library that comes with borland ( <graphics.h> and graphics.lib) As you can see, I am trying to keep it simple. I did think of Allegro as an alternative...
Might try some Borland sites and user groups for tile engines then. If you do go with Allegro, there are a myriad of those things as well. www.allegro.cc is a good place to start the search - there really is a wealth of info in and around it, but sometimes it can be a bit tedious to find it.
Allegro precompiled Installer for Dev-C++, MSVC, and Borland: http://galileo.spaceports.com/~springs/
I appreciate it. I was going to modify the Doom source code, but then i decided to do a tile engine... but since i got a link to an allegro installer, Ill probably use it to compile the Doom source. So, i guess its back to writing that socket code for Doom!
I need a link to some Allegro tile-based engine tutorials. I got one, but when I put it into the game, the game goes below 1 FPS!
Here is my engine code, the reason it is so slow is probably because of the switch statement.
If anyone knows a faster way to do this plz tell me. I know making another function to draw one tile could speed it up, and using pointers in a weird way would speed it up, but how?Code:void draw_map() { int right=0; int down=0; int drawpointx=0; int drawpointy=0; while (right!=25 && down!=18) { switch (cell[right][down]) { case 0: tilebuffer=load_bitmap("castlefloor.bmp",default_palette); break; case 1: tilebuffer=load_bitmap("castlewall.bmp",default_palette); break; } blit(tilebuffer,grid,0,0,drawpointx,drawpointy,tilebuffer->w,tilebuffer->h); right++; drawpointx+=16; if (right==25) { down++; right=0; drawpointy+=16; drawpointx=0; } } blit(grid,screen,0,0,0,0,SCREEN_W,SCREEN_H); }
The problem isn't with the switch statement, it is with this:
tilebuffer=load_bitmap("castlefloor.bmp",default_p alette);
You do this for each tile and every time is access the hard drive to load the bmp. Hard drive access takes nanodays and could definietly knock you down to 1 FPS. Best to load both tiles into memory:
Hope that makes sense.PHP Code:
BITMAP *Tiles[2];
...
Tile[0]=load_bitmap("castlefloor.bmp",default_palette);
Tile[1]=load_bitmap("castlewall.bmp",default_palette);
...
void draw_map()
{
int right=0;
int down=0;
int drawpointx=0;
int drawpointy=0;
while (right!=25 && down!=18)
{
if (cell[right][down]) // Castle wall.
blit(Tile[1],grid,0,0,drawpointx,drawpointy,tilebuffer->w,tilebuffer->h);
else // Castle floor.
blit(Tile[0],grid,0,0,drawpointx,drawpointy,tilebuffer->w,tilebuffer->h);
right++;
drawpointx+=16;
if (right==25)
{
down++;
right=0;
drawpointy+=16;
drawpointx=0;
}
}
blit(grid,screen,0,0,0,0,SCREEN_W,SCREEN_H);
}
-Justin
P.S. Stray_Bullet, good luck on Doom. Just remember that a project like that will take lots o patience. Have fun.
Last edited by Justin W; 03-21-2002 at 10:48 AM.
Allegro precompiled Installer for Dev-C++, MSVC, and Borland: http://galileo.spaceports.com/~springs/
I didn't relize that accessing the HD was so slow. I had a tile engine before, and the reason it was so slow is it had like 3 switch statements and like four if's! That was the same week I just learned how to plot pixels on the mode13h screen, so it was good for what my knowledge was back then. I bet there is a way to speed this up with pointers, but I'll have to come up with that later.
thx, man.