Skip to content
Alex Egorov edited this page Jan 13, 2017 · 9 revisions

Level

From the gameplay point of view, level consists of following elements:

  • Background, which scrolls from top to bottom, representing player craft's movement. Speed of background scrolling is a powerful tool, which can set general pace of the gameplay.
  • Music themes, which start and finish at certain points of the level.
  • Lesser enemies, coming in waves, with pre-defined attack and movement patterns.
  • Boss (one or more), with a number of attack-movement patterns and so on.
  • Suggestion (for future): message box with text, used for advancing through the story, or declaring level name at start, final score at end and so on.
  • Different pick-ups, appearing on the screen or dropping from defeated enemies.

From technical point of view

Level is a list of events spanning in time in some manner. Events may be strictly sequential, or they can relate to each other in some manner, if level has some branching, and may have quite complex logical relationships in general.

Examples of events:

  • Delay -- just wait. Between enemy waves, for example.
  • Enemy wave starts
  • Musical theme changes
  • Level ends (due to player death or to successful finish)
  • Background advance (since e.g. boss fights may vary in length, background must have a way to skip/warp/loop)
  • Change of background scrolling speed (in fact, a special case of previous point)
  • Some message appears and awaits for user confirmation
  • Pick-up appears

Examples of event relationship:

  • Boss fight starts after enemy wave has ended
  • Level ends after final boss fight
  • Music theme changes after sevaral waves have passed
  • Background changes after user have read through messagebox series, in which we told sad story of our craft pilot
  • Pick-up drops out of defeated enemy
  • Pick-up scrolls down from the top after wave/boss have been successfully cleared

Level module

Resides in level.py. Contains class LevelPlayer, base class for all levels -- BaseLevel and a number of Event classes. The following hierarchieal (actually compound) structure is currently planned:

         ConcreteLevel --------p-l-a-y-b-a-c-k--------> LevelPlayer
    ┌──────────┴────────────┐                                │ 
    │                       │                           [EventQueue]
[Events]               [Resources]
                            ├─ Background
                            ├─ Sounds
                            ├─ Music
                            ├─ Enemies
                            ├─ EnemyWaves
                            ├─ Bosses
                            └─ Pick-ups

Let't take a closer look at all of them.

EventQueue Current queue of events to be emitted and handled. May contain logical events, handling forks in plot, repeats, and so on, which replace/modify EventQueue contents in their handling procedure.

Events Pool of all events, extracted from all logical resources, e.g. EnemyWave, Boss, etc. Events are created on level loading stage, and then pumped by pieces into EventQueue, by events themselves. It may be a list, may be a bunch of named fileds, to ease access by event handlers.

Resources This should have dedicated page, for earch resource respectively. They are pretty self-explanatory though. A list, or again a bunch of class fields which are initialized at level loading step.

Classes info

Event Classes

Interface Methods:

  • __next__ - actual workload, all level logic, varying from type to type

Fields:

  • Various, may be missing.

Event classes contain all necessary information to deal with state of game course, and also may contain own list of events, i.e. events are recursive in nature. For example,StartEnemyWave event may contain reference to actual EnemyWave instance, which has it's own list of events, which are recursively emited on enclosing event processing. Lesser events do the actual job -- spawn new enemy crafts with animations, attack patterns, and so on. Event handling occurs

In case of delay event, it just spawns timer which hogs event processor and forbids event advance until delay has expired.

Message event's handle method should schedule message box appearence and process keyboard events, and update message box's contents accordingly.

Background advance event changes current background speed, or changes loop, or whatever.

Level Classes

Interface methods:

  • load -- loads and inits concrete resources.
  • start -- entry point, which is called by LevelPlayer at the start of playback. Must return the first Event of the level.

Fields:

  • Various fields for resource access.

Subclasses:

  • Various event classes (maybe)

Methods:

  • Event handlers. Since many events must know about particular resources, e.g. logic branching event, which may launch one or other enemy wave depending of user choise, their code must have access to them.

Level Player

Interface methods:

  • load -- loads level, which must be already initialized.
  • start -- starts level from the beginning, purging the EventQueue and resetting all events to pristine state, and calling start method of the Level, which returns first events to be places in the Queue.
  • update -- updates event at the top of the Queue, until it finishes and thus removed from the Queue.

Fields:

  • EventQueue -- queue of events to be processed.
Clone this wiki locally