Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 244 | chris | 1 | #ifndef __BOARD_H__ |
| 2 | #define __BOARD_H__ |
||
| 3 | |||
| 4 | ////////////////////////////////////////////////////////////////////////// |
||
| 5 | // Board.h |
||
| 6 | // |
||
| 7 | // This is the third class to look at in this particular demo |
||
| 8 | // (after main.cpp and GameApp.h/.cpp). The Board class is where most of |
||
| 9 | // your actual game programming will go. It is here that we will do |
||
| 10 | // all our game drawing, updating, and input processing. Of course, in |
||
| 11 | // a larger application, you would probably do drawing and updating in |
||
| 12 | // multiple files, but you would still most likely use something similar |
||
| 13 | // to a Board class as the master game logic class. |
||
| 14 | // |
||
| 15 | // The reason that the Board class is a widget is because when a widget |
||
| 16 | // is added to the GameApp's WidgetManager, it will automatically have its |
||
| 17 | // Update and Draw methods called, and it will automatically receive input |
||
| 18 | // at the appropriate times. Furthermore, by making it a widget and adding |
||
| 19 | // it to the WidgetManager, the game logic loop, Update(), will be guaranteed |
||
| 20 | // to run at a standard 100FPS on all machines. This is extremely important |
||
| 21 | // as you always want your logic code to run at the same speed, but want |
||
| 22 | // the drawing code to run as fast as possible. That way on faster machines |
||
| 23 | // your program doesn't run its logic faster than on a slower machine. |
||
| 24 | // |
||
| 25 | // You can think of the Board as a canvas upon which we do all our |
||
| 26 | // drawing, and a central hub where if we need to, we instruct other |
||
| 27 | // classes where and when to draw to. |
||
| 28 | ////////////////////////////////////////////////////////////////////////// |
||
| 29 | |||
| 30 | // This file must be included so that we can derive our Board class from it |
||
| 31 | #include "SexyAppFramework/Widget.h" |
||
| 32 | |||
| 33 | // We place all our classes inside the "Sexy" namespace to avoid name collisions |
||
| 34 | // with other libraries that might be added. |
||
| 35 | namespace Sexy |
||
| 36 | { |
||
| 37 | |||
| 38 | |||
| 39 | // Forward declare the graphics class. You will see the graphics class used |
||
| 40 | // and explained in Board.cpp: it is the main object used to draw all |
||
| 41 | // images, fonts, etc. |
||
| 42 | class Graphics; |
||
| 43 | |||
| 44 | // We maintain a pointer to the main game application in the Board class. |
||
| 45 | // The main game app contains functions that are often times needed |
||
| 46 | // by the Board class, such as registry reading/writing, file reading/writing, |
||
| 47 | // etc. |
||
| 48 | class GameApp; |
||
| 49 | |||
| 50 | ////////////////////////////////////////////////////////////////////////// |
||
| 51 | ////////////////////////////////////////////////////////////////////////// |
||
| 52 | class Board : public Widget |
||
| 53 | { |
||
| 54 | |||
| 55 | private: |
||
| 56 | |||
| 57 | GameApp* mApp; |
||
| 58 | |||
| 59 | |||
| 60 | public: |
||
| 61 | |||
| 62 | ////////////////////////////////////////////////////////////////////////// |
||
| 63 | // Function: Board |
||
| 64 | // Parameters: |
||
| 65 | // theApp - Pointer to the main application class |
||
| 66 | // |
||
| 67 | // Returns: none |
||
| 68 | ////////////////////////////////////////////////////////////////////////// |
||
| 69 | Board(GameApp* theApp); |
||
| 70 | |||
| 71 | virtual ~Board(); |
||
| 72 | |||
| 73 | |||
| 74 | ////////////////////////////////////////////////////////////////////////// |
||
| 75 | // Function: Draw |
||
| 76 | // Parameters: |
||
| 77 | // g - Graphics object used to draw all images and fonts to the screen. |
||
| 78 | // |
||
| 79 | // Returns: none |
||
| 80 | // |
||
| 81 | // Purpose: Called automatically by GameApp's WidgetManager, this function |
||
| 82 | // is the main method that is responsible for all graphical and textual |
||
| 83 | // displaying. |
||
| 84 | ////////////////////////////////////////////////////////////////////////// |
||
| 85 | virtual void Draw(Graphics* g); |
||
| 86 | |||
| 87 | ////////////////////////////////////////////////////////////////////////// |
||
| 88 | // Function: Update |
||
| 89 | // Parameters: none |
||
| 90 | // Returns: none |
||
| 91 | // |
||
| 92 | // Purpose: Called automatically by GameApp's WidgetManager, this method |
||
| 93 | // is GUARANTEED to be called 100 times per second (100FPS) and is where |
||
| 94 | // all main game logic is performed. Of course, if you had a larger more |
||
| 95 | // complex game, you'd most likely divide your logic between several |
||
| 96 | // other files, but this is commonly the central place where all game |
||
| 97 | // logic begins and is executed. |
||
| 98 | ////////////////////////////////////////////////////////////////////////// |
||
| 99 | virtual void Update(); |
||
| 100 | |||
| 101 | }; |
||
| 102 | |||
| 103 | |||
| 104 | } |
||
| 105 | |||
| 106 | #endif // __BOARD_H__ |