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

9.5. The cSpriteIcon class

The author did a lot of coding and encapsulating in order to come up with a cSprite child class called cSpriteIcon. cSpriteIcon has a constructor cSpriteIcon(int resourceID) which takes the ID of a bitmap resource as its argument. To make things nicer, the cSpriteIcon will automatically make the background of the image transparent. To give a critter a transparent-background sprite based on a resource bitmap with an ID like, say, IDB_EARTH, we only need to add a single line to the critter’s constructor.

setSprite(new cSpriteIcon(IDB_EARTH)); 

We also have the option of not having a transparent background at all. The full prototype of the cSpriteIcon constructor looks like this.

 cSpriteIcon(int resourceID, BOOL transparent ...

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