From 94dbe83cfe7255aa87f8ac7073408d3a1cb20121 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 1 Mar 2026 11:04:00 +0000 Subject: [PATCH] Refine asteroids: faster, sparser, with horizontal drift MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- TODO.md | 8 +++----- assets/levels/moon01.lvl | 31 ++++++++----------------------- src/game/hazards.c | 10 ++++++++-- src/game/hazards.h | 7 +++++-- 4 files changed, 24 insertions(+), 32 deletions(-) diff --git a/TODO.md b/TODO.md index 91249e8..5afe45a 100644 --- a/TODO.md +++ b/TODO.md @@ -26,8 +26,6 @@ Ship landing at exit zone when player approaches — player enters, ship takes off, triggers level transition. The intro/start sequence is done; this is the exit counterpart. -## Asteroid refinement -- Reduce asteroid count significantly — occasional hazard, not a barrage -- Add slight horizontal drift so they fall at an angle rather than straight down -- Increase fall speed for more impact -- Stagger spawns more widely across the level +## ~~Asteroid refinement~~ ✓ +Implemented: base speed 120→200, accel 200→350, respawn 3→6s, stagger 0-3→0-8s, +random horizontal drift (±60 px/s), moon level reduced from 24 to 8 asteroids. diff --git a/assets/levels/moon01.lvl b/assets/levels/moon01.lvl index 4adbda7..f8307bb 100644 --- a/assets/levels/moon01.lvl +++ b/assets/levels/moon01.lvl @@ -14,29 +14,14 @@ PLAYER_UNARMED ENTITY spacecraft 1 14 -ENTITY asteroid 66 1 -ENTITY asteroid 70 1 -ENTITY asteroid 74 1 -ENTITY asteroid 77 1 -ENTITY asteroid 89 2 -ENTITY asteroid 92 2 -ENTITY asteroid 95 2 -ENTITY asteroid 97 2 -ENTITY asteroid 100 2 -ENTITY asteroid 109 0 -ENTITY asteroid 112 0 -ENTITY asteroid 115 0 -ENTITY asteroid 118 0 -ENTITY asteroid 141 1 -ENTITY asteroid 144 1 -ENTITY asteroid 147 1 -ENTITY asteroid 150 1 -ENTITY asteroid 154 1 -ENTITY asteroid 162 2 -ENTITY asteroid 165 2 -ENTITY asteroid 168 2 -ENTITY asteroid 171 2 -ENTITY asteroid 174 2 +ENTITY asteroid 68 1 +ENTITY asteroid 85 2 +ENTITY asteroid 96 1 +ENTITY asteroid 113 0 +ENTITY asteroid 130 2 +ENTITY asteroid 148 1 +ENTITY asteroid 163 2 +ENTITY asteroid 178 0 EXIT 196 17 2 3 assets/levels/level01.lvl diff --git a/src/game/hazards.c b/src/game/hazards.c index 8e70d4a..81aed48 100644 --- a/src/game/hazards.c +++ b/src/game/hazards.c @@ -632,14 +632,19 @@ static void asteroid_update(Entity *self, float dt, const Tilemap *map) { ad->falling = true; ad->trail_timer = 0; ad->fall_speed = ASTEROID_FALL_SPEED; + /* Randomize drift direction each fall */ + ad->drift_x = ((float)(rand() % 201) - 100.0f) / 100.0f * ASTEROID_DRIFT_MAX; } return; } /* Accelerate while falling (gravity-like) */ - ad->fall_speed += 200.0f * dt; + ad->fall_speed += ASTEROID_ACCEL * dt; self->body.pos.y += ad->fall_speed * dt; + /* Apply horizontal drift */ + self->body.pos.x += ad->drift_x * dt; + /* Tumble animation */ animation_update(&self->anim, dt); @@ -794,12 +799,13 @@ Entity *asteroid_spawn(EntityManager *em, Vec2 pos) { ad->spawn_pos = pos; ad->falling = true; ad->fall_speed = ASTEROID_FALL_SPEED; + ad->drift_x = ((float)(rand() % 201) - 100.0f) / 100.0f * ASTEROID_DRIFT_MAX; ad->trail_timer = 0; ad->respawn_timer = 0; /* Stagger start times based on spawn position to avoid all falling at once */ ad->start_delay = (pos.x * 0.013f + pos.y * 0.007f); ad->start_delay = ad->start_delay - (float)(int)ad->start_delay; /* frac part */ - ad->start_delay *= 3.0f; /* 0-3s stagger */ + ad->start_delay *= 8.0f; /* 0-8s stagger */ e->data = ad; animation_set(&e->anim, &anim_asteroid); diff --git a/src/game/hazards.h b/src/game/hazards.h index 14ae80b..1aa0d5b 100644 --- a/src/game/hazards.h +++ b/src/game/hazards.h @@ -95,13 +95,16 @@ Entity *force_field_spawn(EntityManager *em, Vec2 pos); #define ASTEROID_WIDTH 14 #define ASTEROID_HEIGHT 14 -#define ASTEROID_FALL_SPEED 120.0f /* base fall speed (px/s) */ +#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 3.0f /* seconds before respawning */ +#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 */