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/engine.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/engine.cpp')
-rw-r--r-- | src/engine.cpp | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index c15d1964..e20e453e 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -242,6 +242,36 @@ Engine::~Engine() delete itemset; } +void Engine::logic() +{ + // Update beings + std::list<Being*>::iterator beingIterator = beings.begin(); + while (beingIterator != beings.end()) + { + Being *being = (*beingIterator); + + if (being->job < 10) { // A player + if (being->action != STAND && being->action != SIT + && being->action != DEAD) { + being->frame = + (get_elapsed_time(being->walk_time) * 4) / (being->speed); + + if (being->frame >= 4) { + being->nextStep(); + } + } + } + + if (being->action == MONSTER_DEAD && being->frame >= 20) { + delete being; + beingIterator = beings.erase(beingIterator); + } + else { + beingIterator++; + } + } +} + void Engine::draw() { // Get the current mouse position @@ -349,15 +379,6 @@ void Engine::draw() being->emotion = 0; } } - if (being->action != STAND && being->action != SIT - && being->action != DEAD) { - being->frame = - (get_elapsed_time(being->walk_time) * 4) / (being->speed); - - if (being->frame >= 4) { - being->nextStep(); - } - } } else if (being->job == 45) { // Draw a warp } else { // Draw a monster @@ -389,13 +410,7 @@ void Engine::draw() } } - if (being->action == MONSTER_DEAD && being->frame >= 20) { - delete being; - beingIterator = beings.erase(beingIterator); - } - else { - beingIterator++; - } + beingIterator++; // nodes are ordered so if the next being y is > then the // last drawed for fringe layer, draw the missing lines |