Quick question about handling 2d levels

Started by
2 comments, last by Brain 8 years, 11 months ago

After a long time doing other things I decided to pick up and finish my first game. It's a 2D Platformer with tile-based levels. However, due to not having coded at all in a long time, I'm a bit rusty and need some advice on how to handle levels.

The last thing I did was create a state engine. I want my game to be level based with an overworld where new levels are gradually unlocked, like Super Mario World for example.

My question is: Should I create a state for every level, or a single level state that reads from a level manager? Is any of these options better than the other, more common, or outright bad practice? Or it does not really matter as long as it works for me?

Thank you very much in advance. :-)

Advertisement

Should I create a state for every level, or a single level state that reads from a level manager?

There should be a single state for gameplay, another for overworld, etc.
Data is what changes from stage-to-stage. A “level manager” is ambiguous and likely not what you want. The game engine should simply be able to take any stage data and have your character be able to walk through it, etc.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Should I create a state for every level, or a single level state that reads from a level manager?

There should be a single state for gameplay, another for overworld, etc.
Data is what changes from stage-to-stage. A “level manager” is ambiguous and likely not what you want. The game engine should simply be able to take any stage data and have your character be able to walk through it, etc.

L. Spiro

Thanks for your answer. :-)

So, as I see it, I'll have a level (gameplay) state and an overworld state, and have the overworld determine what level file should be loaded, kind of like a glorified menu.

Seems simple enough. :-)

Thanks again. :-)

there are lots of ways to approach this.

If you did it like super mario brothers, you would have your 'overworld' be above view and it would require different collision, different rendering, etc.

Alternatively, you could just have your overworld level be another side scrolling level, matching the design of normal levels, perhaps at a different scale. You could then have doors, pipes, portals or whatever to warp to the selected level by jumping on them, pressing 'up', etc. This would be less complex in terms of coding.

The decision as always is your own :)

This topic is closed to new replies.

Advertisement