forked from tas/major_tom
Dedicated Mars Base generator with 6 segment types (entry, shaft, corridor, turret hall, hive, arena), depth-scaled difficulty, and exit to boss arena after 2 generated levels. Mars themes integrated into all 7 generic segment generators. Full level chain: moon03 → mars01 → mars02 → mars_base (×2) → mars03 → station. Also: jetpack fuel pickup preserves recharge progress, depth counters reset on game loop, NULL checks on entity spawns, charger charge timeout, bg decoration in Mars Base generator.
90 lines
3.9 KiB
C
90 lines
3.9 KiB
C
#ifndef JNR_LEVELGEN_H
|
|
#define JNR_LEVELGEN_H
|
|
|
|
#include "engine/tilemap.h"
|
|
#include <stdint.h>
|
|
|
|
/* ═══════════════════════════════════════════════════
|
|
* Procedural Level Generator
|
|
*
|
|
* Generates a Tilemap directly in memory by stitching
|
|
* together segment templates. Supports:
|
|
* - Mixed layouts (horizontal, vertical, arena)
|
|
* - Enemy and hazard placement
|
|
* - Difficulty scaling via seed
|
|
* - Dumping to .lvl format for inspection
|
|
* ═══════════════════════════════════════════════════ */
|
|
|
|
/* Level theme — affects layout, hazards, gravity, atmosphere */
|
|
typedef enum LevelTheme {
|
|
THEME_PLANET_SURFACE, /* alien planet exterior: open terrain, pits,
|
|
flame vents, harsh conditions, high gravity */
|
|
THEME_PLANET_BASE, /* research outpost on a planet: corridors,
|
|
force fields, turrets, medium gravity */
|
|
THEME_SPACE_STATION, /* orbital station: shafts, platforms, low
|
|
gravity, moving platforms, turrets */
|
|
THEME_MARS_SURFACE, /* Mars exterior: red dusty terrain, wind,
|
|
wide-open with charger enemies */
|
|
THEME_MARS_BASE, /* Mars base interior: very vertical, narrow
|
|
corridors, turrets, laser turrets, spawners*/
|
|
THEME_COUNT
|
|
} LevelTheme;
|
|
|
|
#define MAX_THEME_SEQUENCE 10
|
|
|
|
/* Generator configuration */
|
|
typedef struct LevelGenConfig {
|
|
uint32_t seed; /* RNG seed (0 = random from time) */
|
|
int num_segments; /* how many segments to stitch (2-10) */
|
|
float difficulty; /* 0.0 = easy, 1.0 = hard */
|
|
float gravity; /* level gravity override (0 = auto) */
|
|
|
|
/* Theme sequence: one theme per segment.
|
|
* If theme_count == 0, all segments use themes[0].
|
|
* If theme_count > 0, segment i uses themes[min(i, theme_count-1)].
|
|
* Transition segments are auto-inserted at theme boundaries. */
|
|
LevelTheme themes[MAX_THEME_SEQUENCE];
|
|
int theme_count; /* number of entries in themes[] */
|
|
} LevelGenConfig;
|
|
|
|
/* Default config for quick generation */
|
|
LevelGenConfig levelgen_default_config(void);
|
|
|
|
/* Config preset for a space station level:
|
|
* very long horizontally, narrow playable area,
|
|
* near-zero gravity, all THEME_SPACE_STATION.
|
|
* depth (0-based) escalates difficulty and length
|
|
* with each subsequent station level. */
|
|
LevelGenConfig levelgen_station_config(uint32_t seed, int depth);
|
|
|
|
/* Generate a level directly into a Tilemap struct.
|
|
* The Tilemap will have layers allocated, tile defs set,
|
|
* entity spawns populated, and metadata configured.
|
|
* Caller must eventually call tilemap_free() on it.
|
|
* Returns true on success. */
|
|
bool levelgen_generate(Tilemap *map, const LevelGenConfig *config);
|
|
|
|
/* Generate a space-station level: very long, narrow,
|
|
* near-zero gravity. Uses its own segment pool tuned
|
|
* for horizontal layouts in tight corridors.
|
|
* Returns true on success. */
|
|
bool levelgen_generate_station(Tilemap *map, const LevelGenConfig *config);
|
|
|
|
/* Config preset for a Mars Base level:
|
|
* tall (46 tiles), vertical, claustrophobic.
|
|
* Heavy laser turret/spawner/charger presence.
|
|
* depth (0-based) escalates difficulty and length. */
|
|
LevelGenConfig levelgen_mars_base_config(uint32_t seed, int depth);
|
|
|
|
/* Generate a Mars Base level: tall multi-level underground
|
|
* facility with shafts, turret halls, spawner hives.
|
|
* Returns true on success. */
|
|
bool levelgen_generate_mars_base(Tilemap *map, const LevelGenConfig *config);
|
|
|
|
/* Dump a generated (or any) Tilemap to a .lvl file.
|
|
* Useful for inspecting/editing procedural output.
|
|
* Returns true on success. */
|
|
bool levelgen_dump_lvl(const Tilemap *map, const char *path);
|
|
|
|
#endif /* JNR_LEVELGEN_H */
|