Summary


When you write a game with a character moving around in a world, the character must have contact with solid objects. This includes objects that the character bumps into and picks up.

If your character must encounter an object that doesn't move but blocks his movement in the scene, the simplest way to program that is to have the object's image be part of the background. You simply position a bounding rectangle at that location in the scene. When the character hits the bounding rectangle, his progress stops.

For more complex objects that the character bumps into, you can create the object as a sprite or as a collection of layered sprites. Game programmers call layering sprites in a scene 2.5D programming. The easiest way to do 2.5D programming is to simply load the back sprites into the scene before the front sprites. That way, the back sprites are drawn first. When the game draws the front sprites, they cover the parts of the back sprites that need to be covered.

Game characters usually pick up objects by walking over them. Games draw such objects in the scene as sprites that turn invisible after they're picked up.

In the next chapter, we'll wrap things up by demonstrating how to add Slugwroths to the level.



Creating Games in C++(c) A Step-by-Step Guide
Creating Games in C++: A Step-by-Step Guide
ISBN: 0735714347
EAN: 2147483647
Year: N/A
Pages: 148

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