Creating a map engine.

This is a discussion on Creating a map engine. within the Game Programming forums, part of the General Programming Boards category; Basically I'm doing a 3D RPG. Not, like, actual 3D rendering and crap. Think Wizardry. Anyway, basically, my main idea ...

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    106

    Creating a map engine.

    Basically I'm doing a 3D RPG. Not, like, actual 3D rendering and crap. Think Wizardry.

    Anyway, basically, my main idea is to have four "bands" of depth in the dungeon view. These would basically just lie on top of eachother. Each band is basically showing whatever's on the map up to four "spaces" away from the player.

    Anyway, so I basically need to figure out how to do a map engine or something. The most direct method, of course, would just be to define some sort of room class and link them all together with pointers. The problem with this is that I'd need to recompile every time I made a new map. That'd and it'd take for-freaking-ever to do.

    Basically, I'm guessing I'll need to store the map data in a text file. The map in the text would be made out of ascii, and each letter/character/number I use would represent some specific layout; 1 could be a normal straight hallway, 2 would mark a door on the left side, 3 would mark just the hallway turning left, etc. That wouldn't be too terrible to do.

    I assumed I'd then read it into a matrix or something, and then... update the player's x/y coords and compare this against the matrix.

    My main issue here is that I'm not sure exactly how to associate the images I'd be using with the data on the map. Would I need to map one of the symbols I meantioned earlier to... a specific surface using a map?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Just create tile sets. Then you can use the same set of symbols to represent all rooms in each map, but you just store some place in your file what tile set to use. Then do something like setting up the value of any given square to match a specific tile.

    Also, you don't need to recompile every time you make a new map. You just make some way to dynamicly load a file when you need to. It reads what it needs from the file to tell it what to expect, then reads in the map and sets it up in memory.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Dec 2004
    Posts
    465
    Uuummmm It's a 3d RPG with 2 dimensions? Wow, you are very creative.
    My computer is awesome.

  4. #4
    ---
    Join Date
    May 2004
    Posts
    1,379
    I haven't played any of the old Wizardry games but I think he means the games like the old Might and Magic games where it is first person view with 2D graphics to look 3D.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    106
    "Just create tile sets."

    Er, I know. That's what I've done. Basically create a generic structure of some sort to hold said tileset and load in whichever one matches the dungeon I'm in, and then have it place them in accordance to the set of symbols on a map.

    What I'm not sure about is how exatly I go about having the program determine which "tile" to load for which symbol on the map.

    "Also, you don't need to recompile every time you make a new map."

    I know. I mean manually linking room objects up in the source code by that. Obviously, of course, that's NOT what I'm doing here.

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by sand_man
    I haven't played any of the old Wizardry games but I think he means the games like the old Might and Magic games where it is first person view with 2D graphics to look 3D.
    No. He means Wizardry. (But Xeen did the same sort of thing.)

    What I'm not sure about is how exatly I go about having the program determine which "tile" to load for which symbol on the map.
    What's not to know? Simply decide what character or value you want to represent a tile, and stick that in your map. Then when ever they move to the square, based on what way they're facing, display the correct tile. It's just as simple as if you wanted to display a certain character based on a keystroke. Instead, you're displaying a graphic.

    Code:
    char c[] = "abcdefghij";
    int key;
    
    printf("Enter a single digit number: ");
    key = getchar() - '0';
    
    if( key > -1 && < 10 )
    {
        printf("The key %d represents \'%c\'.\n", key + '0', c[ key ] );
    }
    else
        printf("Dumbass!\n");
    
    return 0;

    Quzah.
    Hope is the first step on the road to disappointment.

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    106
    ER, let me rephrase this in pseudo code.

    if symbol == T
    then blit image1.jpg to screen.
    if symbol == Z
    then blit image2.jpg to screen.

    Etc.

    Or, I guess a switch/case would work.

    The things is, is there a way to do this beside using if statements? The problem is, I have a lot of possible symbols. I'd also have to run through the if statement four times, given that the player can view ahead four places.

  8. #8
    ---
    Join Date
    May 2004
    Posts
    1,379
    >The problem is, I have a lot of possible symbols. I'd also have to run through the if statement four times, given that the player can view ahead four places.

    I downloaded the game to look at it and I think that each image displayed just looks like the next one in the distance; Only one image is displayed at a time. Maybe I misunderstood you.

  9. #9
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    So what again is wrong with an array?
    Code:
    int translatesymboltolookup( char symbol );
    ...
    struct graphicdata { } tiles[ SETS ][ MAXTILESPERSET ];
    ...
    
    something = tiles[ thismapset ][ translatesymboltolookup( thissymbol ) ];

    Quzah.
    Hope is the first step on the road to disappointment.

  10. #10
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by sand_man
    I downloaded the game to look at it and I think that each image displayed just looks like the next one in the distance; Only one image is displayed at a time. Maybe I misunderstood you.
    I'm not sure what you mean, as your wording isn't clear.
    Yes and no. It's looks as a tile composet of:

    a) The room ahead and to the left of you.
    b) The room you're in.
    c) The room[s] ahead of you in the distance.
    d) The room ahead and to the right of you.

    Because if you look at it, you can see off into the distance. (I know, I've played this to death back in the day.)
    Code:
     --------
    |\      /|
    | \----/ |
    | |    | |
    | /----\ |
    |/      \|
     --------
    In the left frame, you could see the room that would be that direction, if there wasn't a solid wall, or if you could see out a window, etc. The right frame does the same thing. The top frame is the sky. The center out far would be the next room ahead in the distance. The bottom the floor. Depending, some times you could see two, three rooms ahead of you. Their tile would show their left and right exits, if any.


    Quzah.
    Hope is the first step on the road to disappointment.

  11. #11
    ---
    Join Date
    May 2004
    Posts
    1,379
    Ok Im going to leave this thread alone before I confuse myself even more.

  12. #12
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    If we are talking about static pictures, raycast the image.
    If we are talking about 3D use portals.

    If we are talking about just 2D, use tiles.

    In either case, use an array of ID's which directly correspond to the textures. Your array is a paint by ID type system where ID 1 might be a wall texture, and ID 2 might be a floor texture.

    Animation then comes down to changing ID's over time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating a map
    By DanFraser in forum C# Programming
    Replies: 7
    Last Post: 01-23-2009, 05:23 AM
  2. Creating a map with a new object type
    By blacknail in forum C++ Programming
    Replies: 6
    Last Post: 11-24-2008, 09:16 AM
  3. Polynomials and ADT's
    By Emeighty in forum C++ Programming
    Replies: 20
    Last Post: 08-19-2008, 08:32 AM
  4. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  5. Creating a map of objects with variable width and height
    By MrSparky in forum C++ Programming
    Replies: 6
    Last Post: 07-30-2007, 03:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21