• Advertisement
Sign in to follow this  

Loading a Map from text file

This topic is 2346 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

I have a framework set up for a 2D side scrolling game, with a constant background that is scrolled, and my player can now move around in the scene but now I want to place my certain sprites in certain exact locations of the game world. How do I do that.. I don't have any idea about this (please describe from basic)...

Share this post


Link to post
Share on other sites
Advertisement
Well, if the map is complex enough, you might want to build a simple map editor. Nothing fancy, just something to allow you to select a sprite, and place it in a 2d Grid. Next you should save the map that you have built with your editor to a text (or binary) file. For ever tile, you should write an ID (You might have different tiles; wall, lava, cloud, whatever). Then the X and Y coordinates of the tile. You might also want to add more information, for example a flag to specify whether the tile can be walked on, or might set off a certain event, which would also require an ID of it's own.

Finally when you load the game, just loop through all the tiles in your map file.

Share this post


Link to post
Share on other sites
You just asked this question here: [url="http://www.gamedev.net/topic/608770-map-loading/"]Previous Post[/url]

Why did U make another one exactly the same?

Share this post


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

  • Advertisement