From 7a5963118947000cd9038cf68cc6b5d3cb5c7194 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Mon, 5 Sep 2011 21:55:23 +0200 Subject: [PATCH] Simplify bullet code even more. --- code/bullets.cpp | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/code/bullets.cpp b/code/bullets.cpp index 77f6a8c..61f4971 100644 --- a/code/bullets.cpp +++ b/code/bullets.cpp @@ -187,30 +187,19 @@ void fireBullet(object *attacker, int weaponType) } else { - switch (theWeapon->ammo[0]) + if(theWeapon->ammo[0] & 1) + addBullet(theWeapon, attacker, y * 3, 0); + + if(theWeapon->ammo[0] >= 2) { - case 1: - addBullet(theWeapon, attacker, y * 3, 0); - break; - case 2: - addBullet(theWeapon, attacker, y * 2, 0); - addBullet(theWeapon, attacker, y * 4, 0); - break; - case 3: - addBullet(theWeapon, attacker, y * 2, 0); - addBullet(theWeapon, attacker, y * 3, 0); - addBullet(theWeapon, attacker, y * 4, 0); - break; - case 4: - addBullet(theWeapon, attacker, y, 0); - addBullet(theWeapon, attacker, y * 2, 0); - addBullet(theWeapon, attacker, y * 4, 0); - addBullet(theWeapon, attacker, y * 5, 0); - break; - case 5: - for (int i = 1 ; i < 6; i++) - addBullet(theWeapon, attacker, y * i, 0); - break; + addBullet(theWeapon, attacker, y * 2, 0); + addBullet(theWeapon, attacker, y * 4, 0); + } + + if(theWeapon->ammo[0] >= 4) + { + addBullet(theWeapon, attacker, y * 1, 0); + addBullet(theWeapon, attacker, y * 5, 0); } } @@ -532,7 +521,7 @@ void doBullets() addExplosion(bullet->x, bullet->y, E_TINY_EXPLOSION); } - if ((bullet->flags & WF_AIMED) || (bullet->flags & WF_SPREAD)) + if ((bullet->flags & WF_AIMED)) { blit(bullet->image[0], (int)(bullet->x - bullet->dx), (int)(bullet->y - bullet->dy)); }