Refine asteroids: faster, sparser, with horizontal drift

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.
This commit is contained in:
Thomas
2026-03-01 11:04:00 +00:00
parent 49ed2d6f7b
commit 94dbe83cfe
4 changed files with 24 additions and 32 deletions

View File

@@ -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);

View File

@@ -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 */