17.2 Scenes and Design


17.2 Scenes and Design

Most every computer game requires careful consideration toward its design, particularly when it comes to scenes. A game grows in size and complexity when the number of scene objects, sounds, and resources grows along with various options and features that define how all the objects relate to one another. Sooner or later a management structure must be created to manage all the items in a scene.

Let's take as an example a magic carpet game where the player controls an Arabian boy with his genie lantern, both seated on a flying carpet that whizzes through the gaming environment. In this scenario, several game objects are already defined: the boy, the lantern, and the carpet, and whatever other objects might be part of the environment. The whole scene shares the same coordinate space, and each scene object has its own position within that coordinate space; each object can have a position expressed from the origin (for example, (5, 10)), and also in relation to other objects in the scene. As the player presses the left or right arrow keys, the magic carpet moves appropriately left or right, and as expected its position within the scene changes accordingly. However, as the carpet moves, we expect that everything seated upon it-the boy and the lantern-will also move with the carpet. We don't typically expect them to be left suspended in mid-air as the carpet moves away. So, not only do the carpet, the boy, and the lantern each have a position of their own, but their positions are related to each other because as the position of the carpet changes, the positions of the boy and lantern also change.

The example just discussed is a simple problem we will address in this chapter, but on the whole it is illustrative of the importance of good scene management. If a scene consists of many different objects it's likely there will be many relationships in which the positions and orientation of objects are dependent upon the properties of other objects. Because objects are therefore not entirely autonomous of one another, and relationships exist between objects, it would then be extremely difficult to model and maintain this data without the help of a dedicated scene manager. Without a scene manager to systematically handle such issues, a programmer would need to write reams and reams of code simply to sustain and manage a scene which the scene manager could do in a fraction of the space and with a fraction of the complexity. To all intents and purposes then, a scene manager makes sense. It can be seen as a manager that stores and groups all the objects in a scene, maintains the positions of objects, and expresses the relationships between them.




Introduction to Game Programming with C++
Introduction to Game Programming with C++ (Wordware Game Developers Library)
ISBN: 1598220322
EAN: 2147483647
Year: 2007
Pages: 225
Authors: Alan Thorn

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