O'Reilly logo

SDL Game Development by Shaun Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required