Exercises

Exercise 9.1: Making cSprite::draw non-virtual

If you don’t explicitly label a method as ‘virtual’ in the base class, then the child class overrides will ignore it. Open up the Pop project file and remove the word ‘virtual’ from the line virtual void draw(cGraphics *pgraphics, int drawflags); at the bottom of the sprite.h file. Build and run. You’ll see default base-class imagedraw methods for all the sprites. They’ll be sprites that are drawn as hollow circles.

Exercise 9.2: What happens if you don’t initialize the sprites?

By default every critter gets a base class sprite. If you forget to initialize the sprites you’ll see the same default sprite as in the last exercise. You can test this by going into the gamestub.cpp file and ...

Get Software Engineering and Computer Games 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.