Menu

Map File Format

Paul Barba
2009-04-16
2013-04-18
  • Paul Barba

    Paul Barba - 2009-04-16

    Symphonic recommended the following as the file format for maps. Use this thread to post any comments/recommendations.

    struct BlindMapmakersFile
    {
      int VersionNumber; // this is Version 1
      struct V1HeaderStruct
      {
        int xSize;
        int ySize;
      } Header;
      struct V1TileDictionary
      {
        int NumTiles;
        char TileNames[NumTiles][256]; // null-terminated strings
      } TileDictionary;
      struct V1MapData
      {
        struct V1MapCell
        {
          int Depth; // how many tiles are stacked in this cell (could be a char, how many cells are going to have depth > 255?)
          unsigned int Flags; // properties of the cell, passable? wet? on fire? I dunno...
          int Tiles[Depth]; // each tile is an offset into TileDictionary.TileNames
        } Cells[Header.xSize * Header.ySize];
      } Map;
    };

     
    • Symphonic

      Symphonic - 2009-04-24

      So, after reflecting on Squidi's last post on the original discussion thread (see link 1 below), and thinking a bit about how to keep this simple and both 2D and 3D friendly, I propose this interface:

      This is a C++ declaration for the interface; BUT I think we should definitely make a Java implementation as well. Transcoding should be pretty simple.

      // IBlindMapMaker declaration
      // Derive from this interface to create a blind map-maker compliant map controller
      class IBlindMapMaker
      {
      public:
        // IBlindMapMaker::eDirection Declaration
        // an enumeration to represent directions w.r.t. tiles
        // the choice of order may seem strange;
        // I put east first so that eDirection(0) corresponds to the positive direction on the X axis
        // and they go around counter-clockwise so that rotations are a simple addition & modulo
        enum eDirection {kEastDir, kNorthDir, kWestDir, kSouthDir, kNumDirections};

        // Tile Flags
        typedef static const unsigned int FlagValue;
        FlagValue kFilled = 1; // if set; this tile is the interior of a wall, so it has no walls of its own, and its m_FloorType is drawn at the height of the top of a wall

        // IBlindMapMaker::Tile Declaration
        // a structure to represent a tile
        struct Tile
        {
          int m_FloorType;
          int m_Flags;
          int m_WallTypes[kNumDirections]; // corresponding to each direction in eDirections

          Tile(int floorType, unsigned int flags, int eastWall, int northWall, int westWall, int southWall):
            m_FloorType(floorType),
            m_flags(flags)
          {
            m_WallTypes[0] = eastWall;
            m_WallTypes[1] = northWall;
            m_WallTypes[2] = westWall;
            m_WallTypes[3] = southWall;
          }
        };

        typedef const Tile & TileArg; // easier to type; use these where possible
        static const DefaultTile = Tile(0,0,0,0,0,0);

        // IBlindMapMaker::Resize Declaration
        // Resizes this instance's map to be xSize tiles across and ySize tiles high
        // if the ClearTile Argument is specified then every tile is set to ClearTile
        virtual void Resize(int xSize, int ySize, TileArg ClearTile) = 0;
        inline void Resize(int xSize, int ySize)
        {
          Tile t = DefaultTile;
          this->Resize(xSize, ySize, t);
        }
       
        // IBlindMapMaker::SetTile Declaration
        // Sets a particular tile
        virtual void SetTile(int xLoc, int yLoc, TileArg Tile) = 0;

        // IBlindMapMaker::GetTile Declaration
        // Gets a particular tile
        virtual TileArg GetTile(int xLoc, int yLoc) = 0;
      };

      I think this covers the very basic requirements; Ground, walls, and arbitrary orientability (ie you can spin the view)
      implementations of the interface get to decide how floors and walls are defined and rendered.

      Once we have a viewer implementing this we should begin our first round of generator competition to see what people like/dislike and to collect ideas for extension.

      I'm thinking about the following:
      Static props (furniture, wall decorations, statues, puddles, ???)
      Static Interactibles (Doors, switches, ???)
      non-static interactibles (keys, crates, general pickups, destructibles, movables, ???)

      I have some rough ideas I will flesh out in separate threads later on

      LINKS:
      1: http://squidi.net/forum/index.php?topic=237.msg3221#msg3221

       
    • Paul Barba

      Paul Barba - 2009-04-26

      I converted your map format into java, and added it to the repository.

       

Log in to post a comment.

MongoDB Logo MongoDB