]> git.mxchange.org Git - quix0rs-blobwars.git/blobdiff - src/bullets.cpp
Fix grenades going backwards when the player is moving.
[quix0rs-blobwars.git] / src / bullets.cpp
index fb846423619f294222b60db9f06f273947c22413..b8a416fa1d3ee6f894201416ffff2dd38d8a8b2e 100644 (file)
@@ -49,6 +49,16 @@ void addBullet(Entity *owner, float dx, float dy)
        bullet->id = owner->currentWeapon->id;
        bullet->dx = dx;
        bullet->dy = owner->currentWeapon->dy + dy;
+
+       // Add motion of the player and any platform he/she is on to grenades
+       if (owner->currentWeapon->dy)
+       {
+               int tdx, tdy;
+               getTrainMotion(owner, tdx, tdy);
+               bullet->dx += owner->dx - tdx;
+               bullet->dy += -tdy;
+       }
+
        bullet->next = NULL;
        bullet->health = owner->currentWeapon->health;
        bullet->damage = owner->currentWeapon->damage;