summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-14 20:58:26 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-14 20:58:26 +0000
commit0632377e8b2e63f965b30ac89a9e2dca819735ef (patch)
tree522477ab24f80baa393e0f9ecece14062483c810 /src/game.cpp
parent8381ec4111505692a9058db37412adb872bedd3e (diff)
downloadmana-client-0632377e8b2e63f965b30ac89a9e2dca819735ef.tar.gz
mana-client-0632377e8b2e63f965b30ac89a9e2dca819735ef.tar.bz2
mana-client-0632377e8b2e63f965b30ac89a9e2dca819735ef.tar.xz
mana-client-0632377e8b2e63f965b30ac89a9e2dca819735ef.zip
Added framerate limiter, off by default (0 means no limit)
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 7481ea9a..8c90f329 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -68,8 +68,10 @@ class DeatchNoticeListener : public gcn::ActionListener {
}
} deathNoticeListener;
-
-Uint32 refresh_time(Uint32 interval, void *param)
+/**
+ * Advances game logic counter.
+ */
+Uint32 nextTick(Uint32 interval, void *param)
{
tick_time++;
if (tick_time == MAX_TIME) tick_time = 0;
@@ -80,7 +82,7 @@ Uint32 refresh_time(Uint32 interval, void *param)
* Lets u only trigger an action every other second
* tmp. counts fps
*/
-Uint32 second(Uint32 interval, void *param)
+Uint32 nextSecond(Uint32 interval, void *param)
{
action_time = true;
fps = frame;
@@ -107,6 +109,7 @@ void game()
while (state != EXIT)
{
+ // Handle all necessary game logic
while (get_elapsed_time(gameTime) > 0)
{
do_input();
@@ -115,9 +118,12 @@ void game()
}
gameTime = tick_time;
+ // Draw next frame
gui->logic();
engine->draw();
graphics->updateScreen();
+
+ // Handle network stuff and flush it
do_parse();
flush();
}
@@ -153,8 +159,8 @@ void do_init()
// Initialize timers
tick_time = 0;
- SDL_AddTimer(10, refresh_time, NULL);
- SDL_AddTimer(1000, second, NULL);
+ SDL_AddTimer(10, nextTick, NULL); // Logic counter
+ SDL_AddTimer(1000, nextSecond, NULL); // Seconds counter
// Initialize beings
player_node = new Being();