- Partly implemented client side prediction (still unstable).
[peakengine.git] / engine / include / core / GameEngine.h
blobd4286e22e951cb82dc51a321beec7a175f91ac08
1 /*
2 Copyright (C) 2009 Mathias Gottschlag
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in the
6 Software without restriction, including without limitation the rights to use,
7 copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8 Software, and to permit persons to whom the Software is furnished to do so,
9 subject to the following conditions:
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16 PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 #ifndef _GAMEENGINE_H_
23 #define _GAMEENGINE_H_
25 //#include "core/Config.h"
27 #include <string>
29 #if defined(_MSC_VER) || defined(_WINDOWS_) || defined(_WIN32)
30 #include <time.h>
31 #include <winsock2.h>
32 #include <winbase.h>
33 #define usleep(x) Sleep(x/1000)
34 #else
35 #include <sys/time.h>
36 #endif
38 /**
39 * \brief Namespace which holds all the classes of the engine
41 namespace peak
43 /**
44 * \brief Main game engine class. Calls the other parts of the engine.
46 class GameEngine
48 public:
49 /**
50 * \brief Returns pointer to the GameEngine class.
52 * \return Pointer to the game engine
54 static GameEngine *get(void);
56 /**
57 * \brief Initializes the other parts of the engine and starts the game.
59 * Returns when the engine has been closed.
60 * \param root Path to the data of the game
61 * \return Returns false if there have been errors, else returns true.
63 bool run(std::string root);
65 /**
66 * \brief Stops the game forcefully at the next frame
68 void stopGame(void);
70 /**
71 * \brief Sets the root directory.
73 * Do not use this function!
75 void setRootDirectory(std::string dir);
76 /**
77 * \brief Returns the root directory specified by run().
79 * \return Engine's root directory
81 std::string getRootDirectory(void);
82 private:
83 GameEngine();
85 std::string rootdir;
87 bool stopengine;
89 double lastframe;
93 #endif