How do I organize objects, events, external events, external layouts and global objects for a longer platformer game

I think I can be a great resource for you :sweat_smile:

My Game TripleJump that I just released has a very similar design:

I went with the following main scenes related to gameplay:
Level - This is essentially just the layers and some gui layout, but it has ALL of the game objects defined here AND all of the background assets for every world theme.
Overworld - This is essentially one huge map with different mechanics than the levels, so it only acts as a bridge between levels.

The ā€œLevelā€ scene has a lot of objects in it that are not used in every level, but I didnā€™t find that to be a problem. Each External Layout is named in a world-level style like ā€œ1-1ā€, ā€œ1-2ā€, etc. I use a global variable called ā€œCurrentLevelā€ that is set via the ā€œOverworldā€ and the Level scene logic loads the appropriate External Layout based on that variable.

I considered many times creating a unique Level scene for each world, mostly because it was annoying to sift through nine layers of background images for nine themesā€¦ but eventually I convinced myself that it wasnā€™t worth it because of the maintenance cost: If you want to update an object thatā€™s shared across multiple worlds (like the player sprite) then you would have to do that for every level sceneā€¦ which is prone to manual errorā€¦ itā€™s so easy to just miss one, or to forget to change the collision box in just one of those copiesā€¦ and debugging that would be a nightmare.

Next, you are right on about using External Events for related objects, and for specific functionality. I had Enemies, Objects, GUI, JumpEngine (for all the jump mechanics), TextButtons (my generic button library used in every scene), LevelEngine, BackgroundEngine, TileMapEngine, and JukeBox (to manage background music for each scene).

I also used different objects for each of my platforms, just be sure to create a group called Platforms and add all those objects to the Platforms group. There is no current way in Gdevelop to select objects by behavior. Youā€™ll also want to get in the habit of using object groups for everything thatā€™s relatedā€¦ it will make your logic much more generic and simple. However, maintaining groups is a manual process so itā€™s worth designing some debug code to find any objects that donā€™t have groups assigned, and when you run into a bug check that firstā€¦ it will happen I almost promise.

Just hit me up if you have questions.

2 Likes