12.5. How a listener initializes its owner critter

A final thing to mention about our cListener class is that it has a virtual void install(cCritter *pcritter) method. We attach a listener to a critter with the cCritter::setListener(cListener *plistener) method, and the setListener code calls plistener->install(this) to give the listener a chance to make any necessary adjustments to the critter that is going to start using it.

The default behavior of cListener::install(cCritter *pcritter) is simply to match the pcritter ’s motion matrix to its attitude matrix to get things off to a good start – this match will not automatically be TRUE, as we normally do not lock the player critter’s attitude to its motion. One other use for install is to temporarily ...

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.