File Structure


After you've figured out what objects a game needs and the tasks it performs, designing the game's file structure is fairly straightforward. For each class you define, you should create a .h and a .cpp file. The .h file holds the class definition and the inline member functions. The .cpp file contains the member functions that are too big or too complex to be inline. That's all there is to it. If you follow these guidelines, you'll find it easy to use your objects in your game.

Recall that the LlamaWorks2D game engine uses objects to represent the application and the game. The game engine provides the code for the application class and creates the application object itself. However, you have to use the llamaworks2d::game class the engine provides to create your own game class. Therefore, in addition to a pair of files for your objects, you'll need a .cpp file for your game class. If your game is complex, you may need a .h file for your game class too.

You can see an example of how game files should be structured by looking at the Ping game. Ping has one class for the ball and another for the paddles. Therefore, it has a file called Ping.cpp, a pair of files called Ball.h and Ball.cpp, and another pair named Paddle.h and Paddle.cpp.



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