forked from tas/major_tom
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:
40
src/game/powerup.h
Normal file
40
src/game/powerup.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef JNR_POWERUP_H
|
||||
#define JNR_POWERUP_H
|
||||
|
||||
#include "engine/entity.h"
|
||||
|
||||
/* ═══════════════════════════════════════════════════
|
||||
* Powerup Pickups
|
||||
*
|
||||
* Small collectible items that grant the player
|
||||
* an instant benefit on contact:
|
||||
* - Health: restores 1 HP
|
||||
* - Jetpack: instantly refills all dash charges
|
||||
* - Drone: spawns an orbiting combat drone
|
||||
* ═══════════════════════════════════════════════════ */
|
||||
|
||||
typedef enum PowerupKind {
|
||||
POWERUP_HEALTH,
|
||||
POWERUP_JETPACK,
|
||||
POWERUP_DRONE,
|
||||
POWERUP_KIND_COUNT
|
||||
} PowerupKind;
|
||||
|
||||
typedef struct PowerupData {
|
||||
PowerupKind kind;
|
||||
float bob_timer; /* sine bob animation */
|
||||
Vec2 base_pos; /* original spawn position */
|
||||
} PowerupData;
|
||||
|
||||
/* Register the powerup entity type */
|
||||
void powerup_register(EntityManager *em);
|
||||
|
||||
/* Spawn a specific powerup at a position */
|
||||
Entity *powerup_spawn(EntityManager *em, Vec2 pos, PowerupKind kind);
|
||||
|
||||
/* Convenience spawners for level/levelgen */
|
||||
Entity *powerup_spawn_health(EntityManager *em, Vec2 pos);
|
||||
Entity *powerup_spawn_jetpack(EntityManager *em, Vec2 pos);
|
||||
Entity *powerup_spawn_drone(EntityManager *em, Vec2 pos);
|
||||
|
||||
#endif /* JNR_POWERUP_H */
|
||||
Reference in New Issue
Block a user