diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-04-02 23:47:10 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-04-02 23:47:10 +0000 |
commit | 53120c1bcd812d7036ab3303e0682781f03e42cb (patch) | |
tree | 0faa1c8efded2380cffd2ea618bd2f795485e9eb /src/game.cpp | |
parent | d98bd419b419be1d5069c0fe77fa2a7b6379e45f (diff) | |
download | mana-53120c1bcd812d7036ab3303e0682781f03e42cb.tar.gz mana-53120c1bcd812d7036ab3303e0682781f03e42cb.tar.bz2 mana-53120c1bcd812d7036ab3303e0682781f03e42cb.tar.xz mana-53120c1bcd812d7036ab3303e0682781f03e42cb.zip |
Fixed whobbly walking by separating some logic from the framerate.
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/game.cpp b/src/game.cpp index 19a4c88f..62f15abe 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -51,6 +51,7 @@ int server_tick; int fps = 0, frame = 0, current_npc = 0; bool displayPathToMouse = false; int startX = 0, startY = 0; +int gameTime = 0; OkDialog *deathNotice = NULL; @@ -96,7 +97,8 @@ Uint32 second(Uint32 interval, void *param) return interval; } -short get_elapsed_time(short start_time) { +short get_elapsed_time(short start_time) +{ if (start_time <= tick_time) { return (tick_time - start_time) * 10; } @@ -105,13 +107,23 @@ short get_elapsed_time(short start_time) { } } -void game() { +void game() +{ do_init(); Engine *engine = new Engine(); + gameTime = tick_time; + while (state != EXIT) { - do_input(); + while (get_elapsed_time(gameTime) > 0) + { + do_input(); + engine->logic(); + gameTime++; + } + gameTime = tick_time; + gui->logic(); engine->draw(); graphics->updateScreen(); @@ -172,7 +184,8 @@ void do_init() remove("./docs/packet.list"); } -void do_exit() { +void do_exit() +{ } void do_input() |