15 * This is the core class that glues all the other components together and runs the main loop |
15 * This is the core class that glues all the other components together and runs the main loop |
16 */ |
16 */ |
17 class Engine { |
17 class Engine { |
18 private: |
18 private: |
19 // game state |
19 // game state |
20 GameState game_state; |
20 Terrain *terrain; |
|
21 GameState *game_state; |
|
22 |
|
23 /** Set if setupGraphics has been called */ |
|
24 const GraphicsConfiguration *graphics_config; |
21 |
25 |
22 // Graphics/Input |
26 // Graphics/Input |
23 Graphics *graphics; |
27 Graphics *graphics; |
24 |
28 |
25 // network server/client |
29 // network server/client |
26 NetworkServer *net_server; |
30 NetworkServer *net_server; |
27 NetworkClient *net_client; |
31 NetworkClientConnect *net_client_connect; |
|
32 // XXX: currently unused: NetworkClient *net_client; |
28 |
33 |
29 // to exit the mainloop |
34 // to exit the mainloop |
30 bool is_running; |
35 bool is_running; |
31 |
36 |
32 // ClanLib resources |
37 // ClanLib resources |
34 |
39 |
35 public: |
40 public: |
36 // default constructor |
41 // default constructor |
37 Engine (const std::string resource_xml_path = RESOURCE_XML_PATH); |
42 Engine (const std::string resource_xml_path = RESOURCE_XML_PATH); |
38 |
43 |
|
44 /** |
|
45 * Setup game world using the given terrain, returning the new GameState |
|
46 */ |
|
47 GameState& setupGame (Terrain *terrain); |
|
48 |
|
49 /** |
|
50 * Setup default game world using constants from Config.hh |
|
51 */ |
|
52 GameState& setupGame (void); |
|
53 |
39 // setup graphics |
54 // setup graphics |
40 void setupGraphics (PixelCoordinate resolution, bool fullscreen); |
55 void setupGraphics (const GraphicsConfiguration &config); |
41 |
56 |
42 // set up network server/client |
57 // set up network server/client |
43 // setting up both of these will lead to odd behaviour :) |
58 // setting up both of these will lead to odd behaviour :) |
44 void setupNetworkServer (const std::string &listen_port); |
59 void setupNetworkServer (const std::string &listen_port); |
45 void setupNetworkClient (const std::string &connect_host, const std::string &connect_port); |
60 void setupNetworkClient (const std::string &connect_host, const std::string &connect_port); |
46 void setupSinglePlayer (void); |
61 void setupSinglePlayer (void); |
47 |
62 |
48 // run the main loop |
63 /** |
|
64 * Run the game main loop. This will not return until the game aborts due to an error, or someone calls stop(). |
|
65 */ |
49 void run (void); |
66 void run (void); |
|
67 |
|
68 /** |
|
69 * Terminate the main loop, causing run() to return once this loop iteration is finished |
|
70 */ |
|
71 void stop (void); |
50 |
72 |
51 // terminate the main loop |
73 private: |
52 void stop (void); |
74 /** |
|
75 * Actually start graphics, requires that game_state is now set |
|
76 */ |
|
77 void startGraphics (void); |
53 |
78 |
54 public: |
79 public: |
55 // get a pointer to our resource manager |
80 // get a pointer to our resource manager |
56 CL_ResourceManager* getResourceManager (void); |
81 CL_ResourceManager* getResourceManager (void); |
57 |
82 |