Jump to content
  • Advertisement
Sign in to follow this  
ISDCaptain01

How to draw different mappy maps in the same game

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

Im trying to make a Zelda 1 clone. I have already made my field/main map. But say I want to make cave map for whenever a player enters a cave. How would I draw this? I have already made the cave map made.

I load in my overworld map like this
MapLoad("overworld.fmp", 1);

And draw it like this:
MapDrawBG(mapxoff, mapyoff, x, y, width, height);

But Now I want to draw the cave map, what can I do to tell my program to draw the cave instead of the overworld now?

Share this post


Link to post
Share on other sites
Advertisement

Without knowing what your structure looks like or how mappy works, your best bet is probably to load in the cave map/retrieve it from memory and draw that and don't draw the overworld map.

 

If mappy only allows you to draw/load one map at a time, you can either keep on un and reload the maps needed, or construct your maps in such a way that everything is on the map and all you need to do is get the right coords to get to your caves position. Either way is rather un-efficient though.

 

Best way probably is to load in surrounding areas and draw them when entering that area, but it kind of depends how mappy works to make that work.

Share this post


Link to post
Share on other sites

Hacky and quick way:

In it's simplest form, you could probably have an entire map for your underworld. Make your "cave" level the entire size of your map. Any entrances down into the underworld would be in the same corresponding position of your overland map. You wouldn't have to change your mapxoff, mapyoff, x, y, width, or height variables. You'd only have to load "cave.fmp" instead.

 

I'd only do this as a way of exploring what all needs to become more sophisticated. Some things that may or may not need some more smarts: Monsters, NPC's, and Chest's spring to mind. If you haven't specified which "map" they are a part of, everything that spawns on map screen (3, 14) of the overland would also spawn on 3, 14 of the underworld.

 

Side note: This is a prime example of how global variables can come back to bite you.

 

More sophisticated way:

You'll need a way to keep up with some map data and which map the player is on. Since I don't use Mappy, some of this may be done for you already, but I'll assume not.  I'd make a MapData class and store all the core data of the map there. The filename, what types and number of enemies that spawn on what screen, which music to play, and lists of any kind of special tiles like entrances, burnable bushes, explodable rocks, raft launching spots, etc.

 

For now I'll concentrate on the "entrance" of the overland map to a cave map. The entrance on the overland will need to know specifically where it is on the overland map (screen and tile coordinate), which mapData the entrance takes the player to (cave1), and where specifically it starts you at on the destination map (mapxoff, mapyoff, x, y). 

 

In order to leave the cave, I would create an "entrance" in the cave1 MapData that leads back to a specific point on the overland MapData.

 

Create a variable for currentMapData and wire up your game logic to use the data we specified (such as enemy spawning, or the map's music). 

In your game logic, you can check for the player entering this special "entrance" tile. When they do, you'll want to load up the destinationMap, set the mapxoff, mapyoff, x, y, and set currentMapData to your cave1 mapData.

 

Now when your game loop loads a screen, it should be spawning the enemies specific to cave1's data.

 

I hope this helps,

- Eck

Share this post


Link to post
Share on other sites

Well I do have a state machine implemented in the game. Im thinking of this:

When I leave the overworld, Ill leave the overworld state and clear out the map. Once I get into

the cave state, I load up the cave map and draw it in the rendering area of my game loop.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!