//--- // level: Static level model // // This module provides representations for read-only data structures // describing levels, from which dynamic maps can be built. The only role of // models is that we can import them into the game and then load them into // maps. This is a convenience to abstract away the storage format of levels. //--- #pragma once #include "fixed.h" #include "map.h" #include "item.h" #include #include #include /* A level wave is a list of pairs (enemy identity, amount) pairs which indicate how many enemies to spawn. The order might be random and another dynamically-allocated structure is used in game_t to keep track of this assignment. */ typedef struct { int entry_count; struct { uint8_t identity; uint8_t amount; } *entries; } level_wave_t; enum { /* Nothing happens for a short while */ LEVEL_EVENT_DELAY = 0, /* A wave of monster spawns! */ LEVEL_EVENT_WAVE = 1, /* An item is dropped at a random position */ LEVEL_EVENT_ITEM = 2, }; /* Levels are made of a sequence of simple events. */ typedef struct { int type; fixed_t duration; union { /* LEVEL_EVENT_DELAY: Nothing */ /* LEVEL_EVENT_WAVE */ level_wave_t *wave; /* LEVEL_EVENT_ITEM */ int item; }; } level_event_t; typedef struct { char const *name; map_t const *map; /* Player spawn location */ uint8_t player_spawn_x; uint8_t player_spawn_y; /* Spawner positions */ int spawner_count; uint8_t *spawner_x; uint8_t *spawner_y; /* List of events (the array is not terminated) */ int event_count; level_event_t *events; } level_t; /* Get the number of waves in a level */ int level_wave_count(level_t const *lv); /* List of levels */ extern level_t level_lv1; extern level_t level_lv2;