Jump to content
  • Advertisement
Sign in to follow this  
RojanShrestha

Loading a Map from text file

This topic is 2617 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
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!