Jump to content

  • Log In with Google      Sign In   
  • Create Account


How to draw different mappy maps in the same game


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 ISDCaptain01   Members   -  Reputation: 1245

Like
0Likes
Like

Posted 07 February 2014 - 03:03 AM

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?



Sponsor:

#2 Rld_   Members   -  Reputation: 1327

Like
0Likes
Like

Posted 07 February 2014 - 03:31 AM

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.



#3 Eck   Members   -  Reputation: 1636

Like
0Likes
Like

Posted 07 February 2014 - 08:48 AM

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



#4 ISDCaptain01   Members   -  Reputation: 1245

Like
0Likes
Like

Posted 07 February 2014 - 02:08 PM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS