Main Menu

Modular map making

Started by Plystire, September 17, 2012, 09:42:44 PM

Previous topic - Next topic

Plystire

I'm in the design phase of my project (alongside learning PB's commandset) and for part of my game I want to create collision maps modularly.

Think of these maps like a jigsaw puzzle. I want to be able to take one map and put it next to another map, which would be pieced with another map. This would allow me to make many map setups with very few collision maps. What I'm not sure about is whether PB's internal map system will allow me to do that. From what I've seen, there is no way to position a map at all.

Now, I was thinking that since collision checks are called manually, it may be possible to emulate the maps being in different positions by simply calling a collision check on a particular map using an offset to the character's position (bringing the character's position to where it would be if the map were located at 0,0). So assuming I want my small map to be located at 250,750 and the character is at 350,500 I would call the collision check like so:
MapX = 250
MapY = 750
PlayerNewX = 350
PlayerNewY = 500
CheckMapImpact(map,lvl, PlayerX - MapX, PlayerY - MapY, PlayerNewX - MapX, PlayerNewY - MapY, PlayerWid, PlayerHit)


MapX and MapY are the emulated position of the map. By offsetting the player's coordinates with the map coordinates, the check will be performed as though the character were near the origin where the map is located.

Of course, I wouldn't run checks on every map unnecessarily. Collision checks would only be performed if the character's new position was inside the bounds of the map to be checked.

Doing this, we should be able to produce a large map out of reusable small maps. :)

I haven't tried this yet, but the logic makes sense.

What I want to know is if a method like this exists using PB internal commands. I'm not totally familiar with PB's map and world system yet.

~Plystire

LemonWizard

Well.. for map modularity... I don't know if you'll entirely understand this codebase but here is the entire codebase to my present version of my donkey kong country 2 game engine which I actually plan to Fork into another game engine I'm going to be calling a special name soon.

If you have any questions regarding how my engine works please let me know. You can't run the source but if you want me to I can upload the full playable system for you to tinker with.
It doesn't use playbasic's map system at all (teehee)

Unfortunately it won't let me post it here so I'll link offsite to pastebin.
Enjoy :3 http://pastebin.com/07D6gbi9