Thread: Tile engines

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    6

    Tile engines

    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!

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    375
    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/

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    6

    Currently I am....

    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...

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    375
    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/

  5. #5
    Registered User
    Join Date
    Mar 2002
    Posts
    6

    Cool

    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!

  6. #6
    Unregistered
    Guest
    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.

    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);
    }
    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?

  7. #7
    Registered User
    Join Date
    Oct 2001
    Posts
    375
    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:

    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);

    Hope that makes sense.

    -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/

  8. #8
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Weather in 2D tile engines
    By VirtualAce in forum Game Programming
    Replies: 7
    Last Post: 09-26-2006, 03:05 PM
  2. Need testers for editor
    By VirtualAce in forum Game Programming
    Replies: 43
    Last Post: 07-10-2006, 08:00 AM
  3. Tile map loading/saving
    By sand_man in forum Game Programming
    Replies: 16
    Last Post: 04-23-2005, 09:38 PM
  4. Tile Engine Scripting Idea. Suggestions?
    By napkin111 in forum Game Programming
    Replies: 8
    Last Post: 07-28-2003, 02:01 PM
  5. Tile Editor
    By Nick in forum Linux Programming
    Replies: 3
    Last Post: 08-10-2001, 11:24 PM