Handling bullets
Most objects in the game fire bullets and they all pretty much need to be checked for collisions against bullets as well; the bottom line—bullets are important in Alien Attack. The game has a dedicated BulletHandler
class that handles the creation, destruction, updating, and rendering of bullets.
Two types of bullets
There are two types of bullets in the game, PlayerBullet
and EnemyBullet
, both of which are handled in the same
BulletManager
class. Both of the bullet classes are declared and defined in Bullet.h
:
class PlayerBullet : public ShooterObject { public: PlayerBullet() : ShooterObject() { } virtual ~PlayerBullet() {} virtual std::string type() { return "PlayerBullet"; } virtual void load(std::unique_ptr<LoaderParams> pParams, Vector2D heading) { ShooterObject::load(std::move(pParams)); m_heading = heading; } virtual void draw() { ShooterObject::draw(); } virtual void collision() { m_bDead = true; } virtual...