Add per-level wind atmosphere property
WIND directive in .lvl files sets a constant horizontal force (px/s^2) that pushes entities, projectiles, and particles. Positive is rightward. Wind is applied as acceleration in physics_update() (halved on ground), directly to projectile and particle velocities, and as a gentle position drift on flyers. Entities with gravity_scale=0 (drones, spacecraft) are unaffected. Levels default to no wind when the directive is absent.
This commit is contained in:
@@ -170,6 +170,13 @@ static void flyer_update(Entity *self, float dt, const Tilemap *map) {
|
||||
float bob_offset = sinf(fd->bob_timer * FLYER_BOB_SPD) * FLYER_BOB_AMP;
|
||||
body->pos.y = fd->base_y + bob_offset;
|
||||
|
||||
/* Wind drifts flyers (they bypass physics_update).
|
||||
* Apply as gentle position offset matching first-frame physics. */
|
||||
float wind = physics_get_wind();
|
||||
if (wind != 0.0f) {
|
||||
body->pos.x += wind * dt * dt;
|
||||
}
|
||||
|
||||
/* Chase player if in range */
|
||||
Entity *player = find_player(s_flyer_em);
|
||||
if (player && player->active && !(player->flags & ENTITY_DEAD)) {
|
||||
|
||||
Reference in New Issue
Block a user