O'Reilly logo

Software Engineering and Computer Games by Rudy Rucker

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

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

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