Add in-game level editor with auto-discovered tile/entity palettes
Implements a full level editor that runs inside the game engine as an alternative mode, accessible via --edit flag or E key during gameplay. The editor auto-discovers available tiles from the tileset texture and entities from a new central registry, so adding new game content automatically appears in the editor without any editor-specific changes. Editor features: tile painting (pencil/eraser/flood fill) across 3 layers, entity placement with drag-to-move, player spawn point tool, camera pan/zoom, grid overlay, .lvl save/load, map resize, and test play (P to play, ESC to return to editor). Supporting changes: - Entity registry centralizes spawn functions (replaces strcmp chain) - Mouse input + raw keyboard access added to input system - Camera zoom support for editor overview - Zoom-aware rendering in tilemap, renderer, and sprite systems - Powerup and drone sprites/animations wired up (were defined but unused) - Bitmap font renderer for editor UI (4x6 pixel glyphs, no dependencies)
This commit is contained in:
90
src/game/hazards.h
Normal file
90
src/game/hazards.h
Normal file
@@ -0,0 +1,90 @@
|
||||
#ifndef JNR_HAZARDS_H
|
||||
#define JNR_HAZARDS_H
|
||||
|
||||
#include "engine/entity.h"
|
||||
#include "engine/camera.h"
|
||||
#include "engine/tilemap.h"
|
||||
|
||||
/* ═══════════════════════════════════════════════════
|
||||
* TURRET — Wall/floor-mounted gun that shoots at
|
||||
* the player when in range, on a cooldown timer.
|
||||
* ═══════════════════════════════════════════════════ */
|
||||
|
||||
#define TURRET_WIDTH 14
|
||||
#define TURRET_HEIGHT 16
|
||||
#define TURRET_DETECT_RANGE 160.0f /* detection radius in px */
|
||||
#define TURRET_SHOOT_CD 2.0f /* seconds between shots */
|
||||
#define TURRET_HEALTH 3
|
||||
|
||||
typedef struct TurretData {
|
||||
float shoot_timer; /* countdown to next shot */
|
||||
float fire_flash; /* visual: time remaining on flash */
|
||||
} TurretData;
|
||||
|
||||
void turret_register(EntityManager *em);
|
||||
Entity *turret_spawn(EntityManager *em, Vec2 pos);
|
||||
|
||||
/* ═══════════════════════════════════════════════════
|
||||
* MOVING PLATFORM — Travels back and forth along a
|
||||
* horizontal or vertical path. Player rides on top.
|
||||
* ═══════════════════════════════════════════════════ */
|
||||
|
||||
#define MPLAT_WIDTH 16
|
||||
#define MPLAT_HEIGHT 16
|
||||
#define MPLAT_SPEED 40.0f /* pixels per second */
|
||||
#define MPLAT_RANGE 80.0f /* total travel distance in px */
|
||||
|
||||
typedef struct MovingPlatData {
|
||||
Vec2 origin; /* center of travel path */
|
||||
Vec2 direction; /* (1,0) horizontal / (0,1) vert*/
|
||||
float range; /* half-distance of travel */
|
||||
float phase; /* current sine phase (radians) */
|
||||
} MovingPlatData;
|
||||
|
||||
void mplat_register(EntityManager *em);
|
||||
Entity *mplat_spawn(EntityManager *em, Vec2 pos);
|
||||
/* Spawn with explicit direction: dir (1,0) = horizontal, (0,1) = vertical */
|
||||
Entity *mplat_spawn_dir(EntityManager *em, Vec2 pos, Vec2 dir);
|
||||
|
||||
/* ═══════════════════════════════════════════════════
|
||||
* FLAME VENT — Floor-mounted grate that periodically
|
||||
* bursts blue flames upward. Damages on contact
|
||||
* when flames are active.
|
||||
* ═══════════════════════════════════════════════════ */
|
||||
|
||||
#define FLAME_WIDTH 16
|
||||
#define FLAME_HEIGHT 16
|
||||
#define FLAME_ON_TIME 1.5f /* seconds flames are active */
|
||||
#define FLAME_OFF_TIME 2.0f /* seconds between bursts */
|
||||
#define FLAME_DAMAGE 1
|
||||
|
||||
typedef struct FlameVentData {
|
||||
float timer; /* counts down in current phase */
|
||||
bool active; /* true = flames on */
|
||||
float warn_time; /* brief flicker before igniting*/
|
||||
} FlameVentData;
|
||||
|
||||
void flame_vent_register(EntityManager *em);
|
||||
Entity *flame_vent_spawn(EntityManager *em, Vec2 pos);
|
||||
|
||||
/* ═══════════════════════════════════════════════════
|
||||
* FORCE FIELD — Energy barrier that toggles on/off
|
||||
* on a timer. Blocks movement and damages when
|
||||
* active, passable when off.
|
||||
* ═══════════════════════════════════════════════════ */
|
||||
|
||||
#define FFIELD_WIDTH 16
|
||||
#define FFIELD_HEIGHT 16
|
||||
#define FFIELD_ON_TIME 3.0f /* seconds barrier is active */
|
||||
#define FFIELD_OFF_TIME 2.0f /* seconds barrier is off */
|
||||
#define FFIELD_DAMAGE 1
|
||||
|
||||
typedef struct ForceFieldData {
|
||||
float timer; /* counts down in current phase */
|
||||
bool active; /* true = barrier is on */
|
||||
} ForceFieldData;
|
||||
|
||||
void force_field_register(EntityManager *em);
|
||||
Entity *force_field_spawn(EntityManager *em, Vec2 pos);
|
||||
|
||||
#endif /* JNR_HAZARDS_H */
|
||||
Reference in New Issue
Block a user