map saving question

This is a discussion on map saving question within the Game Programming forums, part of the General Programming Boards category; It means that your map can have a width of 2^31 and a height of the same size, provided there ...

  1. #16
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    It means that your map can have a width of 2^31 and a height of the same size, provided there is enough memory.

    This was created using CMapManager.

    This is all of the maps.
    The following images will show the other layers.
    Last edited by VirtualAce; 12-09-2005 at 04:43 AM.

  2. #17
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Layer 1

  3. #18
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Layer 2

  4. #19
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    And layer 3

  5. #20
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Please keep in mind I have a very limited tile set just to see if the editor works correctly. Hopefully our artists will have more tiles that 'hide the grid' rather than flaunt it.

    This editor so far supports any number of layers, any number of tiles, and it also supports transparent colors so you can do transparent blits.

    When it saves the map, it creates 2 files. One is for the desktop information and it streams all relevant information to the file. The second file is the data file and it uses block I/O to write the data to disk in binary format. So the desktop is serialized via MFC and the maps are written using C standard file I/O.

    Much more left to do. Namely, unlimited undo's and zooming. Zooming is such a pain in the arse because I'm not sure how to re-calc the new scroll values.

    Both of the maps you see, the one in the Tile Picker and the one in the main view window use the same CTileRenderer class. Both of them use the same tile manager, but they use different CMapManagers. This means that you could have a vector of tile maps for the tile picker tool and could place them in a tabbed dialog control so the user could thumb through them. The tab they clicked would act as an index into the vector of maps. This would ensure that the correct tiles were selected based on the currently selected map.

    The movement map is simply a map indicating which tiles are one's the player can walk on. This is a simple lookup into another map during the game and can also be saved just like any other map in the game. More information can be packed into one DWORD of the move map to indicate several other flags.

    The reasons for this approach:
    • Tile maps are usually made up of hundreds of identical tiles. This method ensures that you have 1 copy in memory, but any number of maps and cells can use it. 1 resource used hundreds if not thousands of times.
    • Movement is not encoded into the tile itself. Therefore any tile with any graphic at any time can be made moveable or non-moveable. It's matter of just changing the value in the movement map.
    • Since the CMapManager class can already handle CMaps, the movement map is very simple to use. So when the player or AI walks, their offset values will change. Use the offset value to index into the movement map to determine whether or not the tile can be walked on, falls off when walked on, cannot be walked on, etc, etc.
    • With CMapManager and other manager or container classes you can directly control object lifetime. You know exactly when an item is being deleted and you know you have exactly 1 copy of that object in memory.
    • Indexing into an array is so much faster than attempting to iterate through a linked list and so game performance is increased significantly.
    • The memory footprint for the maps is very small. In fact, if you have a max of 255 tiles in the game (yeah right) and your map is 320x200, one uncompressed layer will take 64kb.
    • Since tiles are simply just ID's that are indexes to the real data in the vectors, animation now boils down to changing ID's over time. So the animation class does NOT have to contain any tile graphic data or pointers. It just contains a list of ID's, a list of frame times, a pointer to the TileManager, and any other relevant information. Simple.


    There are other benefits but those are the main one's.

    Again, not the only way to do a tile system, but so far it's fast and it's extremely easy to use.
    Last edited by VirtualAce; 12-09-2005 at 05:02 AM.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another map question
    By m37h0d in forum C++ Programming
    Replies: 5
    Last Post: 01-26-2009, 09:25 AM
  2. 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
  3. how can I re-sort a map
    By indigo0086 in forum C++ Programming
    Replies: 8
    Last Post: 06-01-2006, 06:21 AM
  4. Saving Map Array To Disk
    By Tommaso in forum Game Programming
    Replies: 4
    Last Post: 07-18-2003, 12:03 AM
  5. Keys of a map
    By nickname_changed in forum C++ Programming
    Replies: 4
    Last Post: 07-10-2003, 04:46 AM

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