9 Replies - 8831 Views - Last Post: 10 March 2013 - 11:45 AM

#1 Toadill  Icon User is offline

  • D.I.C Regular

Reputation: 45
  • View blog
  • Posts: 401
  • Joined: 08-January 12

XNA 4.0, C#, Creating a 2D map editor for an RPG

Posted 12 February 2013 - 10:29 AM

I would like to start creating tools to help create parts of the game I am working on. How would I go about creating a map editor? I want to be able to add objects in the map that are collide-able and set a spawn point within each map. I will also keep track of the cords on the map such as x and y.
The question I have about XNA is how does it load 2D maps, and keep track of this type of information? Does anyone know of a good tutorial on how to create a map editor for XNA, is their a specific format or extension the map should be in? If you can answer any of these questions I would appreciate it, thanks ahead of time.

This post has been edited by Toadill: 12 February 2013 - 10:30 AM


Is This A Good Question/Topic? 0
  • +

Replies To: XNA 4.0, C#, Creating a 2D map editor for an RPG

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9278
  • View blog
  • Posts: 34,789
  • Joined: 12-June 08

Re: XNA 4.0, C#, Creating a 2D map editor for an RPG

Posted 12 February 2013 - 11:17 AM

Quote

How would I go about creating a map editor?

That uniquely is dependant on what game objects are present, how you represent them in your game, and how your game would read a level.


Quote

I want to be able to add objects in the map that are collide-able and set a spawn point within each map.
...
I will also keep track of the cords on the map such as x and y.

Okay.. so typical 'game map'. Heck a 2-d array stored as a text file would work where each node of the array is a value indicating an object.

Quote

The question I have about XNA is how does it load 2D maps, and keep track of this type of information?
...
is their a specific format or extension the map should be in?

No, not really. Again it is up to you. Heck your map editor doesn't even need to be in XNA. You just need a 'map' file output, right? Well this could easily be created in VB.NET, JAVA, etc... and your game reads the file in. Just a thought...


You may want to look to here for some ideas:
http://www.dreaminco...-map-editor1-2/
Was This Post Helpful? 1
  • +
  • -

#3 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: XNA 4.0, C#, Creating a 2D map editor for an RPG

Posted 12 February 2013 - 11:35 AM

If you're set on using XNA, I'd suggest checking out Nick Gravelyn's Tile Engine Tutorial Series. There are 94 videos that take you through the entire process of loading images to use as different types of tiles and how to save and load maps using at first just an array, but later on using XML with several attributes, multiple image files, and a dictionary of tiles. I did the series a long time ago, and it wasn't updated for XNA 4.0, so there are a few small places where you'll need to figure things out for yourself, or ask here for help. I got almost half way through the series and decided to go my own way with it and altered just about everything until I was happy with an editor that I've used a few times. Unfortunately I don't have access to the code for it, or any screenshots at the moment, so give it a try and I'd be happy to help if you get stuck.

Once I get my desktop back up and running, I'll be able to provide a more specific idea of where I decided to take mine including some screen shots.

There have also been several of these threads around here over the past couple of years that I've posted in regarding the information I've given you and how I proceeded to alter the code in order to suit my own needs, so that might be a good place to look as well.

This post has been edited by Kilorn: 12 February 2013 - 11:37 AM

Was This Post Helpful? 1
  • +
  • -

#4 Toadill  Icon User is offline

  • D.I.C Regular

Reputation: 45
  • View blog
  • Posts: 401
  • Joined: 08-January 12

Re: XNA 4.0, C#, Creating a 2D map editor for an RPG

Posted 14 February 2013 - 07:20 AM

View PostKilorn, on 12 February 2013 - 01:35 PM, said:

If you're set on using XNA, I'd suggest checking out Nick Gravelyn's Tile Engine Tutorial Series. There are 94 videos that take you through the entire process of loading images to use as different types of tiles and how to save and load maps using at first just an array, but later on using XML with several attributes, multiple image files, and a dictionary of tiles. I did the series a long time ago, and it wasn't updated for XNA 4.0, so there are a few small places where you'll need to figure things out for yourself, or ask here for help. I got almost half way through the series and decided to go my own way with it and altered just about everything until I was happy with an editor that I've used a few times. Unfortunately I don't have access to the code for it, or any screenshots at the moment, so give it a try and I'd be happy to help if you get stuck.

Once I get my desktop back up and running, I'll be able to provide a more specific idea of where I decided to take mine including some screen shots.

There have also been several of these threads around here over the past couple of years that I've posted in regarding the information I've given you and how I proceeded to alter the code in order to suit my own needs, so that might be a good place to look as well.



These tutorials seem great!

This post has been edited by Toadill: 14 February 2013 - 07:47 AM

Was This Post Helpful? 0
  • +
  • -

#5 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: XNA 4.0, C#, Creating a 2D map editor for an RPG

Posted 14 February 2013 - 07:34 AM

The list he uses is a generic List<Texture2D>. Lists are a fundamental part of the .NET framework, so I assure you, they are there. Perhaps you typed something incorrectly.
Was This Post Helpful? 0
  • +
  • -

#6 tycos  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 53
  • Joined: 12-February 13

Re: XNA 4.0, C#, Creating a 2D map editor for an RPG

Posted 14 February 2013 - 11:20 AM

Worth having a look at mapeditor.org as well, very well written and the map files it produces are used by games such as Catacomb Snatch
Was This Post Helpful? 0
  • +
  • -

#7 Toadill  Icon User is offline

  • D.I.C Regular

Reputation: 45
  • View blog
  • Posts: 401
  • Joined: 08-January 12

Re: XNA 4.0, C#, Creating a 2D map editor for an RPG

Posted 23 February 2013 - 07:26 AM

So far I have built the tileengine, the tileEditor, and the tileGame. This would work great but I do not want to use low res graphics instead I want the game to look like this or better.


Picture

Would this still work?

This post has been edited by Toadill: 23 February 2013 - 07:33 AM

Was This Post Helpful? 0
  • +
  • -

#8 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: XNA 4.0, C#, Creating a 2D map editor for an RPG

Posted 23 February 2013 - 08:35 AM

You can make it look anyway you want. Just change out the files that are being used for the tiles. You can even change the size of the tiles if you find that the current ones are too small or too large.
Was This Post Helpful? 0
  • +
  • -

#9 Toadill  Icon User is offline

  • D.I.C Regular

Reputation: 45
  • View blog
  • Posts: 401
  • Joined: 08-January 12

Re: XNA 4.0, C#, Creating a 2D map editor for an RPG

Posted 10 March 2013 - 11:32 AM

Okay I am running into a problem here with the Tile editor in this tutorial.

Everything works great except when I create a new layer I have a few visual bugs.

The layer is suppose to be covered with the white boxes which is actually a image I have created. But instead it only prints one.

Video

        /************************************************************************************************
        *******************************************Fix Me Here PLS***************************************
        *************************************************************************************************/
        private void Render()
        {
            GraphicsDevice.Clear(Color.Black);

            //Loop through every layer in the TileLayer class
            foreach (TileLayer layer in tileMap.Layers)
            {
                //Draw the tiles
                layer.Draw(spriteBatch, camera);
                //Draw more sprites
                spriteBatch.Begin();
//*********************************************Find empty spots**************************************************************************
                for (int y = 0; y < layer.Height; y++)
                {
                    for (int x = 0; x < layer.Width; x++)
                    {
                        //Find empty tiles
                        if (layer.GetCellIndex(x, y) == -1)
                        {
                            //Call sprite batch draw method
                            spriteBatch.Draw(
                            tileTexture,
                            new Rectangle(
                                x = TileLayer.TileWidth - (int)camera.Position.X,
                                y = TileLayer.TileHeight - (int)camera.Position.Y,
                                TileLayer.TileWidth,
                                TileLayer.TileHeight),
                            Color.White);
                        }
                    }
                }
                //End the sprite Batch
                spriteBatch.End();
            }

            // if the current layer is not null then
            if (currentLayer != null)
            {
                //if the cell x is not -1 and cell y is not -1 then
                if (cellX != -1 && cellY != -1)
                {
                    //Begin the sprite batch
                    spriteBatch.Begin();
                    
                    //Call the spriteBatch Draw method
                    spriteBatch.Draw(
                            tileTexture,
                            new Rectangle(
                                cellX * TileLayer.TileWidth - (int)camera.Position.X,
                                cellY * TileLayer.TileHeight - (int)camera.Position.Y,
                                TileLayer.TileWidth,
                                TileLayer.TileHeight),
                            Color.Red);

                    //End the sprite Batch
                    spriteBatch.End();
                }
            }
        }




This was build in XNA 3.0
I am using 4.0 so I did have to make some changes like using the filestream instead of the old .FromFile method that Texture2D use to use. For what I have seen lots of people have had this problem.

I appreciate any help.
Was This Post Helpful? 0
  • +
  • -

#10 Toadill  Icon User is offline

  • D.I.C Regular

Reputation: 45
  • View blog
  • Posts: 401
  • Joined: 08-January 12

Re: XNA 4.0, C#, Creating a 2D map editor for an RPG

Posted 10 March 2013 - 11:45 AM

Go figure I finally post this problem and then 2 mins later I figure it out.
It was a syntax error


                for (int y = 0; y < layer.Height; y++)
                {
                    for (int x = 0; x < layer.Width; x++)
                    {
                        //Find empty tiles
                        if (layer.GetCellIndex(x, y) == -1)
                        {
                            //Call sprite batch draw method
                            spriteBatch.Draw(
                            tileTexture,
                            new Rectangle(
                                x * TileLayer.TileWidth - (int)camera.Position.X,
                                y * TileLayer.TileHeight - (int)camera.Position.Y,
                                TileLayer.TileWidth,
                                TileLayer.TileHeight),
                            Color.White);
                        }
                    }
                }


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1