src/proto2/Engine.hh
changeset 25 af75a1894a32
parent 24 b81cb670e6b2
child 35 e21cfda0edde
child 56 38f269310f77
equal deleted inserted replaced
24:b81cb670e6b2 25:af75a1894a32
       
     1 #ifndef ENGINE_HH
       
     2 #define ENGINE_HH
     1 
     3 
       
     4 // XXX: forward-declare Engine for other components
       
     5 class Engine;
       
     6 
       
     7 #include "GameState.hh"
       
     8 #include "Graphics.hh"
     2 #include "NetworkServer.hh"
     9 #include "NetworkServer.hh"
     3 #include "NetworkClient.hh"
    10 #include "NetworkClient.hh"
     4 
    11 
     5 #include "Logger.hh"
    12 #include "Logger.hh"
     6 
    13 
     7 class Engine {
    14 class Engine {
     8     private:
    15     private:
     9         // game state
    16         // game state
    10         GameState game_state;
    17         GameState game_state;
    11         
    18         
       
    19         // Graphics/Input
       
    20         Graphics *graphics;
       
    21 
    12         // network server/client
    22         // network server/client
    13         NetworkServer *net_server;
    23         NetworkServer *net_server;
    14         NetworkClient *net_client;
    24         NetworkClient *net_client;
    15 
    25 
    16         // to exit the mainloop
    26         // to exit the mainloop
    17         bool is_running;
    27         bool is_running;
    18         
    28     
       
    29     public:    
    19         // default constructor
    30         // default constructor
    20         Engine (void);
    31         Engine (void);
    21 
    32 
       
    33         // setup graphics
       
    34         void setupGraphics (void);
       
    35         
       
    36         // set up network server/client
       
    37         // setting up both of these will lead to odd behaviour :)
       
    38         void setupNetworkServer (const std::string &listen_port);
       
    39         void setupNetworkClient (const std::string &connect_host, const std::string &connect_port);
       
    40         
       
    41         // run the main loop
       
    42         void run (void);
       
    43 
       
    44         // terminate the main loop
       
    45         void stop (void);
       
    46 
    22     public:
    47     public:
    23         static void runNetworkServer (const std::string &listen_port);
    48         // logging utility
    24         static void runNetworkClient (const std::string &connect_host, const std::string &connect_port);
       
    25         
       
    26                 // logging utility
       
    27         static Logger log (enum LogLevel level, const char *type);
    49         static Logger log (enum LogLevel level, const char *type);
    28 
       
    29     private:
       
    30         void main_loop (void);
       
    31 
    50 
    32 };
    51 };
    33 
    52 
       
    53 #endif /* ENGINE_HH */