XNA Creators Club Online
Page 1 of 1 (5 items)
Sort Posts: Previous Next

Map Editing tool for XNA.

Last post 10/24/2007 6:27 PM by SwampThingTom. 4 replies.
  • 10/21/2007 10:44 AM

    Map Editing tool for XNA.

        Hi guys, I just don't know how to make something and I need some help...
        I have some tilesets in "bitmap" format and I wanto to make a game map with this tiles...
        I Just wanto to know with what tool I can use to "compile o make" this map to import it  on XNA....
        At least tell me what format the map can be to use with XNA.
  • 10/21/2007 11:50 AM In reply to

    Re: Map Editing tool for XNA.

    XNA doesn't have any direct support for tile maps so you'll have to write an importer or loader for whatever map format you use.

    Tile Studio is a freeware program for creating 2D maps with tilesets.  It's not perfect but it does everything you need and the price is right!  ;-)  Another nice thing about it is that you can write your own exporter to save the maps in whatever format you want.  I wrote one to save maps in the format used by XNAResource's Tile Engine Tutorial.  Let me know if you want me to send it to you.  Between Tile Studio and the Tile Engine Tutorial code, you'll have everything you need to create a map and load it into your game.

    Tom

     

  • 10/21/2007 6:23 PM In reply to

    Re: Map Editing tool for XNA.

    Hi, if you send me It whould me a freat help....can u^???
    If yes add me on messenger or send by mail... frogstrike@hotmail.com
    Thanks!!
  • 10/24/2007 6:23 PM In reply to

    Re: Map Editing tool for XNA.

    Sorry for the delay in getting this to you.  Since it may be of use to others as well, I'm going to go ahead and post it rather than email it.

    ; --------------------------------------------------------
    ; Tile Studio Script for XNA Tile Engine Component
    ; from www.xnaresources.com
    ; --------------------------------------------------------
    #file <ProjectName>.map
    #tileset
    #map
    1\n<MapHeight>\n<MapWidth>\n
    #mapdata
    <TSBackTile>\n<TSMidTile>\n<TSFrontTile>\n<MapCode>\n
    #end mapdata
    #end map
    #end tileset
    #end file

    Put that in a file called XNA.tsd in the same directory as the Tile Studio executable.  Once you have created your map in Tile Studio, go to the Code->Code Generation Settings menu item and select XNA.  Then select Code->Generate Code to create the file containing the map.

    You can load it into your game using the following code from XNAResources Tile Engine Tutorial:

            void ReadMapFromFile(string sFileName)
    {
    StreamReader srReader;
    srReader = File.OpenText(sFileName);
    int iReadVersion = Convert.ToInt32(srReader.ReadLine());
    iMapHeight = Convert.ToInt32(srReader.ReadLine());
    iMapWidth = Convert.ToInt32(srReader.ReadLine());
    for (int y = 0; y < iMapHeight; y++ )
    {
    for (int x = 0; x < iMapWidth; x++ )
    {
    iMap[y,x] = Convert.ToInt32(srReader.ReadLine());
    iMapTrans[y, x] = Convert.ToInt32(srReader.ReadLine());
    iMapObjects[y, x] = Convert.ToInt32(srReader.ReadLine());
    iMapWalkable[y, x] = Convert.ToInt32(srReader.ReadLine());
    }
    }
    srReader.Close();
    }
  • 10/24/2007 6:27 PM In reply to

    Re: Map Editing tool for XNA.

    BTW, you may also want to check out this thread that has information about other 2D tile map editors.  I used Tile Studio because it was all I could find at the time.  It met my needs but I'm not completely happy with it, so you should check out some of the others too to decide what you like best.

    Tom

Page 1 of 1 (5 items) Previous Next