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:
@@ -82,6 +82,7 @@ void particle_emit(const ParticleBurst *b) {
|
||||
|
||||
void particle_update(float dt) {
|
||||
float gravity = physics_get_gravity();
|
||||
float wind = physics_get_wind();
|
||||
|
||||
for (int i = 0; i < MAX_PARTICLES; i++) {
|
||||
Particle *p = &s_particles[i];
|
||||
@@ -96,6 +97,11 @@ void particle_update(float dt) {
|
||||
/* Apply gravity */
|
||||
p->vel.y += gravity * p->gravity_scale * dt;
|
||||
|
||||
/* Apply wind (reuse gravity_scale as environmental-force scale) */
|
||||
if (wind != 0.0f && p->gravity_scale > 0.0f) {
|
||||
p->vel.x += wind * p->gravity_scale * dt;
|
||||
}
|
||||
|
||||
/* Apply drag */
|
||||
if (p->drag > 0) {
|
||||
float factor = 1.0f - p->drag * dt;
|
||||
|
||||
Reference in New Issue
Block a user