Wiki

Clone wiki

agtools / Tutorial 4g - Finishing Touches

Outline

ts4g.png

We're going to finish this tutorial by setting up the entities such that they approximate the title sequence from the iconic 'Xenon' game from the Bitmaps.

We already have the behaviour code we need, but there are some loose ends. It looks wrong.

Setup

First we declare an offset adjustment to help us centre things:

static const s16 c_xenon_yoffset = -50;

In the setup code, we specify a 'time separation' constant, which is really just the padding distance between each entity, before it appears onscreen. This controls the sequence of appearing letters (because letters beginning farther away will take longer to move onscreen, and so appear later!).

static const s16 time_separation = 28;

We then adjust the EntitySpawn() calls to add a bunch of offsets representing the starting position of each letter, offscreen. We use the time_separation constant to pad out the order of appearance, as mentioned above.

We have also tweaked the text offset...

static const s16 xenony = (SCREEN_LINES/2)-7+c_xenon_yoffset;

...to be in terms of a more global offset affecting spawn positions, so we can move the whole thing up and down a bit without upsetting the ending conditions (because the AI settles letters at a specific y coordinate)

But these are just offset tweaks. Nothing significant has changed - we really just moved the starting points of the entities. All of the code is basically the same.

Summary

The sequence should now look a bit familiar. The entities all have different starting conditions, different ending conditions, but one common behaviour. And it all runs under its own steam.

So we have now covered:

  • creating multiple instances of different types of entity
  • controlling entities via tick functions
  • maintaining entities in different coordinate spaces
  • working with independent state, starting and ending conditions (where applicable)
  • applying increasing complexity to tick functions

Still, this hasn't been too exciting so far. It's just some moving sprites after all.

The next steps will go deeper into entity dynamics, where the fun really starts.

Updated