QA


Q&A

Q1:

Why does the HandleKeys() function change the velocity of the car sprite in response to the arrow keys, instead of directly changing its position?

A1:

The HandleKeys() function could certainly change the position of the car sprite to get a similar result, but by changing the velocity you get a smoother sense of control in the game. More specifically , the movement of the car isn't choppy because when it changes direction, it actually decelerates and then accelerates again. This is a minor detail, but one that helps to add a touch of realism to the game.

Q2:

Why doesn't the Space Out game include a unique derived Sprite class for each kind of alien?

A2:

The game could have been designed to utilize three derived Sprite classes such as BlobboSprite , JellySprite , and TimmySprite , but in reality it just wasn't necessary to break out the code that much. If the different aliens had required radically different functionality within them, this approach might have made more sense. And if you're a stickler for adhering to object-oriented design, you could still go back and redesign the game around three alien classes instead of one. However, I usually err on the side of simplicity, and in this case one class does the trick just fine.



Sams Teach Yourself Game Programming in 24 Hours
Sams Teach Yourself Game Programming in 24 Hours
ISBN: 067232461X
EAN: 2147483647
Year: 2002
Pages: 271

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net