World maps and my platformerPosted: 2012-01-28
A question I’ve been dealing with recently is how to handle designing the world map for my Flixel-based timed platformer. Why even deal with world maps as a level select? They strike me as important ways to engage the player with curiosity and a sense of exploring and adventure – a prime example would be almost any various ROM-hack of Super Mario World – in many ways, part of the fun is unlocking various levels to see what will pop up next. In addition, they’re incredibly fun to design and draw.
Figuring out how to go about programming one in a clean way has been a bit of a challenge. The Flixel framework seems more than capable of allowing the programmer to do something like this. The new levels must be unlocked/animated when returning to the world map upon success, and player input must be paused – however, we’d like to have animations in the world map while the level is being unlocked.
I have two ideas for implementing this so far…
In my game, levels are unlocked via
A. gaining enough total pickups in the levels (An okay analogy might be the electoons in Rayman, except unlocking more stages than just Candy Chateau) will unlock special levels, and
B. beating a stage opens up an adjacent one.
I was thinking of maintaining a state variable for the World Map – something like “unlockingDone” or what not – which would work a bit like this. Beating a stage will modify a global-state count of the pickups. On the create() method of the World Map class, we can check to see if a new stage needs to be unlocked. If so, we can add it to an array, or perhaps queue of “things to unlock” – then in our update look, we simply set some state variable to prevent player input, and set timers so that after some time interval, pop something off of that queue (or just maintain an incremental index into the array), and animate it. That much seems simple, but I’m wondering how to store it. There seems to be two ways. The first would be to store every set of things to unlock as objects in an external Registry class – maybe “WorldMapObjects” – holding say, the level marker and two smaller markers forming a path to it. It could have an ID, and a boolean, “unlocked”. So when we load the world map, we automatically iterate through the WorldMapObjects and draw every unlocked thing to the screen.
The other way is to just maintain an array (in some global context) of “Levels unlocked”. So in WorldMap’s create(), you call this giant method that checks for every level being unlocked – we can also maintain an array, “Level *just* unlocked”, so if a level isn’t unlocked but was *just* unlocked, we add that level’s world map markers to a queue/array as before, yadda yadda.
Both solutions seem like they’d work, but perhaps the former lends itself to possible re-use, while the latter would be this hacky thing that “works”. Hm.
And of course there’s other cool things – the music, sound effects on the map, how to animate the text for level titles, hmmm…