forked from tas/major_tom
Increase base fall speed (120→200), acceleration (200→350), and respawn delay (3→6s). Add random horizontal drift (±60 px/s) so asteroids fall at angles. Widen initial stagger (0-3→0-8s). Reduce moon level from 24 asteroids to 8, spread evenly across the level.
118 lines
5.7 KiB
C
118 lines
5.7 KiB
C
#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);
|
|
|
|
/* ═══════════════════════════════════════════════════
|
|
* ASTEROID — Falls from the sky, damages the player
|
|
* on contact, explodes on hitting the ground, then
|
|
* respawns at its original position after a delay.
|
|
* ═══════════════════════════════════════════════════ */
|
|
|
|
#define ASTEROID_WIDTH 14
|
|
#define ASTEROID_HEIGHT 14
|
|
#define ASTEROID_FALL_SPEED 200.0f /* base fall speed (px/s) */
|
|
#define ASTEROID_ACCEL 350.0f /* fall acceleration (px/s^2) */
|
|
#define ASTEROID_DRIFT_MAX 60.0f /* max horizontal drift (px/s) */
|
|
#define ASTEROID_DAMAGE 1
|
|
#define ASTEROID_RESPAWN 6.0f /* seconds before respawning */
|
|
|
|
typedef struct AsteroidData {
|
|
Vec2 spawn_pos; /* original position (for reset)*/
|
|
float fall_speed; /* current fall velocity */
|
|
float drift_x; /* horizontal velocity (px/s) */
|
|
float respawn_timer; /* countdown while inactive */
|
|
bool falling; /* true = falling, false = wait */
|
|
float trail_timer; /* particle trail interval */
|
|
float start_delay; /* initial delay before first fall */
|
|
} AsteroidData;
|
|
|
|
void asteroid_register(EntityManager *em);
|
|
Entity *asteroid_spawn(EntityManager *em, Vec2 pos);
|
|
|
|
#endif /* JNR_HAZARDS_H */
|