Jump to content
  • Advertisement
Sign in to follow this  
Cgr

How do I make a 2D/Tile map engine?

This topic is 3905 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm looking for a site, book, or any information you can give me on developing a 2D based tile map feature for my game. It doesn't matter to me if it's isometric or not... I just want to get something started. Also, if you have any information on creating a map editor.. that would be great.

Share this post


Link to post
Share on other sites
Advertisement
Did you check the articles/tutorials in gamedev.net ?
Some of them might be useful for you

Share this post


Link to post
Share on other sites
Yes I have checked articles, and no- I have not found the help I require on this subject.
Anyone else?

Share this post


Link to post
Share on other sites
Quote:
Original post by Ezbez
What do you currently know? Can you program? Have you made a game yet? Are you sure you want to write a game engine?


To answer your questions:
I know C#. I can program. Yes I have made multiple small games. I am sure I want to make an engine. Can I please get advice on the question I posted, instead of this crazy work-out you're putting me through?

Share this post


Link to post
Share on other sites
Work out? Don't you agree that the answers you get depend a lot on what you know? If you've never touched programming before (and trust me, we get a lot of people who wouldn't know a while loop if it bit them, and yet want to start making a game engine), you're going to start by learning that. On the other hand, someone who already knows programming is going to start somewhere else, clearly. That type of information should be given in your original post, but since you didn't, I asked for it.

Now, for your question. It's very difficult to give some wide sweeping article on how to make an engine, due to a couple of reasons:

1. "Game engine" is very ambiguous. What it means varies from no more than a couple of classes to complete game authoring tools, though most definitions are somewhere in the middle.
2. It's a very large topic.
3. There are almost as many 'good' ways to write a game engine as there are game engines.

However, there's certainly some information. The article I linked to above actually gives some quite nice advice as to how to start making a game engine; find parts that are shared between the games you've already made and separate it into an engine. This is a very practical approach and works quite well (I've been doing this method for a number of games I've been writing lately, and I'm building up a nice little code base that handles a lot of the tedious stuff for me).

There's also a somewhat dated series of articles called "Enginuity" on this website. They are respected for some reasons, but certainly has some down-sides as well. They certainly might give you a nice start, especially if you combine it with the previous strategy.

Hope that starts you off.

Share this post


Link to post
Share on other sites
Wait, are you asking about a full 2D game engine, or just something to display a tile-based map? Can't help you with the first one but there's really nothing tricky about tile-based maps. Since you've made small games I imagine you already know how to draw an image to the screen?

For storing your map, you just want a 2-dimensional array. Most likely the array will contain numbers that correspond to different tiles depending on what tile set is being used.

To render a map to the screen, the only slightly tricky part is to only render the tiles that are actually on the screen. My strategy is to figure out what tile is in the upper-left corner of the screen. Since I don't have zooming, I know that the number of tiles that can fit across the screen and down will remain constant, so I draw the upper left tile and then as many tiles down and across as can fit on the screen.

To implement scrolling, just keep track of where the "camera" is. The camera would just be a point representing the position of the screen in the game world. Simply subtract the actual X,Y coordinate of each tile and the position of the camera (or maybe its the other way around...) to get the screen position of each tile. Same goes for in-game objects.

To start off with, try making something that can display a simple map that you can scroll with the arrow keys. If you can do that, you've pretty much got 2D maps down.

Share this post


Link to post
Share on other sites
If your using C# and XNA I found some tutorials that might help you. I havent done them myself yet but it might be what your looking for. They are under the advanced XNA section.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!