Skip to content

Section Order Tricks

ClementSparrow edited this page Oct 7, 2022 · 1 revision

Here are a few tricks that rely on the new ability to split sections anywhere and resume them later and change their order.

Grouping tags, mappings, and objects in pseudo-sections

Instead of defining all the tags in the game, then all the mappings, then all the objects, you can define your own pseudo-sections for different types of objects in your game, possibly even for different mechanics, and then declare in each pseudo-section all the tags, mappings, and objects that matter for this section. The ==== lines are very useful for that as they can be used anywhere in the code, including around comments! Check for instance how I create pseudo-sections in my game Coyote Time Lord.

I also often have parts of the LEGEND in these pseudo-sections too, when that make sense. For instance, if I have a pseudo-section for the basic elements of layout in a level, like backgrounds and walls, this is a nice place to also define the property Obstacle that will group all the types of walls.

Splitting the LEGEND section

I tend to split the LEGEND section in two:

  • One part with only the definitions of synonyms, aggregates, and properties, in a section right before the rules that will use these new words;
  • One part with only the main symbols used in the level maps, just before the LEVELS section.

Keep definitions close to where they're used!

Interlacing LEGEND and LEVELS sections

If your levels are organized in groups, with different objects and mechanics introduced in each group, why not keep things clean and easy to access by declaring the legend symbols used in a group of levels just before this group of levels?

One particular instance of that trick is when you have a single-level world with multiple rooms that were first created as individual levels. Then you probably have two sections of levels in your code, one for the individual levels, and one for the big level that contains them all. It's also likely that you will have different win conditions in both cases (you can split that section too!) and objects specific to the win conditions for individual levels only (for instance, targets or exit doors), and other objects specific for the world-level only (for instance, markers for checkpoints). If you have a section of levels for testing level design ideas or for unit tests, they may benefit from having their own LEGEND section too!