Add new level transition state machine
This commit is contained in:
@@ -6,6 +6,14 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* ── Transition style name → enum mapping ── */
|
||||
static TransitionStyle parse_transition_style(const char *name) {
|
||||
if (strcmp(name, "spacecraft") == 0) return TRANS_SPACECRAFT;
|
||||
if (strcmp(name, "elevator") == 0) return TRANS_ELEVATOR;
|
||||
if (strcmp(name, "teleporter") == 0) return TRANS_TELEPORTER;
|
||||
return TRANS_NONE;
|
||||
}
|
||||
|
||||
/* Read a full line from f into a dynamically growing buffer.
|
||||
* *buf and *cap track the heap buffer; the caller must free *buf.
|
||||
* Returns the line length, or -1 on EOF/error. */
|
||||
@@ -120,6 +128,16 @@ bool tilemap_load(Tilemap *map, const char *path, SDL_Renderer *renderer) {
|
||||
}
|
||||
} else if (strncmp(line, "PLAYER_UNARMED", 14) == 0) {
|
||||
map->player_unarmed = true;
|
||||
} else if (strncmp(line, "TRANSITION_IN ", 14) == 0) {
|
||||
char tname[32] = {0};
|
||||
if (sscanf(line + 14, "%31s", tname) == 1) {
|
||||
map->transition_in = parse_transition_style(tname);
|
||||
}
|
||||
} else if (strncmp(line, "TRANSITION_OUT ", 15) == 0) {
|
||||
char tname[32] = {0};
|
||||
if (sscanf(line + 15, "%31s", tname) == 1) {
|
||||
map->transition_out = parse_transition_style(tname);
|
||||
}
|
||||
} else if (strncmp(line, "EXIT ", 5) == 0) {
|
||||
if (map->exit_zone_count < MAX_EXIT_ZONES) {
|
||||
ExitZone *ez = &map->exit_zones[map->exit_zone_count];
|
||||
|
||||
@@ -58,6 +58,8 @@ typedef struct Tilemap {
|
||||
char parallax_near_path[ASSET_PATH_MAX]; /* near bg image path */
|
||||
int parallax_style; /* procedural bg style (0=default) */
|
||||
bool player_unarmed; /* if true, player starts without gun */
|
||||
TransitionStyle transition_in; /* transition animation for level entry */
|
||||
TransitionStyle transition_out; /* transition animation for level exit */
|
||||
EntitySpawn entity_spawns[MAX_ENTITY_SPAWNS];
|
||||
int entity_spawn_count;
|
||||
ExitZone exit_zones[MAX_EXIT_ZONES];
|
||||
|
||||
Reference in New Issue
Block a user