]> git.mxchange.org Git - quix0rs-blobwars.git/blobdiff - src/bullets.cpp
Make sure the Windows icon is square.
[quix0rs-blobwars.git] / src / bullets.cpp
index 522a262a44e3bbfb3d70b36b5dc38586230d03fa..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;
@@ -81,7 +91,7 @@ void addBullet(Entity *owner, float dx, float dy)
 
        if (owner->currentWeapon->fireSound > -1)
        {
-               audio.playSound(owner->currentWeapon->fireSound, CH_WEAPON);
+               audio.playSound(owner->currentWeapon->fireSound, CH_WEAPON, owner->x);
        }
 
        if (owner->flags & ENT_AIMS)
@@ -133,7 +143,7 @@ void destroyBullet(Entity *bullet)
 
        if (bullet->flags & ENT_SPARKS)
        {
-               audio.playSound(bullet->deathSound, CH_TOUCH);
+               audio.playSound(bullet->deathSound, CH_TOUCH, bullet->x);
        }
 
        if (bullet->flags & ENT_EXPLODES)
@@ -183,7 +193,7 @@ void bounceBullet(Entity *bullet, float dx, float dy)
                if (bullet->id != WP_LASER)
                {
                        bullet->dx *= 0.75;
-                       audio.playSound(SND_GRBOUNCE, CH_TOUCH);
+                       audio.playSound(SND_GRBOUNCE, CH_TOUCH, bullet->x);
                }
                bullet->face = !bullet->face;
        }
@@ -201,7 +211,7 @@ void bounceBullet(Entity *bullet, float dx, float dy)
                if (bullet->id != WP_LASER)
                {
                        bullet->dy *= 0.75;
-                       audio.playSound(SND_GRBOUNCE, CH_TOUCH);
+                       audio.playSound(SND_GRBOUNCE, CH_TOUCH, bullet->x);
                }
 
                if ((bullet->dy > -2) && (bullet->dy <= 0)) bullet->dy = -2;
@@ -233,7 +243,7 @@ bool bulletHasCollided(Entity *bullet, float dx, float dy)
                                {
                                        Math::removeBit(&bullet->flags, ENT_BOUNCES);
                                        map.data[x][y] = MAP_AIR;
-                                       audio.playSound(SND_STONEBREAK, CH_EXPLODE);
+                                       audio.playSound(SND_STONEBREAK, CH_EXPLODE, bullet->x);
                                        throwBrickParticles(x << BRICKSHIFT, y << BRICKSHIFT);
                                }
                                else
@@ -241,7 +251,7 @@ bool bulletHasCollided(Entity *bullet, float dx, float dy)
                                        if ((Math::prand() % 2) == 0)
                                        {
                                                map.data[x][y] = MAP_AIR;
-                                               audio.playSound(SND_STONEBREAK, CH_EXPLODE);
+                                               audio.playSound(SND_STONEBREAK, CH_EXPLODE, bullet->x);
                                                throwBrickParticles(x << BRICKSHIFT, y << BRICKSHIFT);
                                        }
                                }
@@ -264,7 +274,7 @@ bool bulletHasCollided(Entity *bullet, float dx, float dy)
        
        checkSwitchContact(bullet);
 
-       if ((checkTrainContact(bullet, 0)) || (checkObstacleContact(bullet, 0)))
+       if ((checkTrainContact(bullet, DIR_XY)) || (checkObstacleContact(bullet, DIR_XY)))
        {
                if (bullet->flags & ENT_BOUNCES)
                        bounceBullet(bullet, dx, dy);