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, ...
Get SDL Game Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.