As a rule, once you have a cCritter::move that gives you a visually convincing simulation of some reasonably accurate physics, you shouldn't override it at all. If you ignore this rule, you run the risk of developing a game that runs great on your home machine, but which behaves badly when you bring the program in for a classroom demo “ or, if you're working alone, when you try and show it off at a conference or at a friend's house. The critters may seem to be barely moving at all “ or flying around the screen like neutrinos. All the careful work in calculating a real time dt and passing it to your critters is going to make no difference if you make the cCritter::move(dt) method a virtual method and override it with a method that ignores dt and does something like _position += _velocity . Remember that it's only if you have the proper move code of _position += dt * _velocity that your program is going to adjust the motions of your critters to take into account the actual speed at which your game is running. It should be possible to make all your changes to your critter motions by adding in forces to get used in the update call to feelforce , or by directly editing the update method.
We'll talk more about the user controls and the cListener class in Chapter 12: Listeners. For now though, we might as well mention some of the ways that some of our standard listeners change the main player critter's motion in response to an arrow key or a mouse action. Most of the time, a critter using a listener will ignore any acceleration due to forces. We ignore physics in order to have the player critter be fully responsive to the game's user.
|