From ab9debf3fa91f3b36c6739f4affbdc187e78113d Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 13 Mar 2005 01:16:52 +0000 Subject: * Moved Being public char *speech to private std::string speech * Moved Being public PATH_NODE *path to private std::list path * Fixed warping issue which corrupted player (which also applies to respawning) * Got rid of sound error in Setup window --- src/engine.cpp | 46 ++++++++++++++-------------------------------- 1 file changed, 14 insertions(+), 32 deletions(-) (limited to 'src/engine.cpp') diff --git a/src/engine.cpp b/src/engine.cpp index 8ba4e7ea..36e6c212 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -407,10 +407,8 @@ void Engine::draw() being->frame = (get_elapsed_time(being->walk_time) * 4) / (being->speed); - if (being->frame >= 4) { - if (being->action != MONSTER_DEAD && being->hasPath()) { - being->nextStep(); - } + if (being->frame >= 4 && being->action != MONSTER_DEAD) { + being->nextStep(); } } } @@ -436,28 +434,26 @@ void Engine::draw() // purposes. if (displayPathToMouse) { - PATH_NODE *debugPath = tiledMap->findPath( + std::list debugPath = tiledMap->findPath( player_node->x, player_node->y, mouseX / 32 + camera_x, mouseY / 32 + camera_y); - while (debugPath) + while (!debugPath.empty()) { - int squareX = (debugPath->x - camera_x) * 32 - offset_x + 12; - int squareY = (debugPath->y - camera_y) * 32 - offset_y + 12; + PATH_NODE node = debugPath.front(); + debugPath.pop_front(); + + int squareX = (node.x - camera_x) * 32 - offset_x + 12; + int squareY = (node.y - camera_y) * 32 - offset_y + 12; guiGraphics->setColor(gcn::Color(255, 0, 0)); guiGraphics->fillRectangle(gcn::Rectangle(squareX, squareY, 8, 8)); - MetaTile *tile = tiledMap->getMetaTile(debugPath->x, debugPath->y); + MetaTile *tile = tiledMap->getMetaTile(node.x, node.y); std::stringstream cost; cost << tile->Gcost; guiGraphics->drawText(cost.str(), squareX + 4, squareY + 12, gcn::Graphics::CENTER); - - // Move to the next node - PATH_NODE *temp = debugPath->next; - delete debugPath; - debugPath = temp; } } @@ -466,24 +462,10 @@ void Engine::draw() while (beingIterator != beings.end()) { Being *being = (*beingIterator); - if (being->speech != NULL) { - //if (being->speech_color == makecol(255, 255, 255)) { - // guiGraphics->drawText(being->speech, - // being->text_x + 16, being->text_y - 60, - // gcn::Graphics::CENTER); - //} - //else { - guiGraphics->drawText(being->speech, - being->text_x + 60, being->text_y - 60, - gcn::Graphics::CENTER); - //} - - being->speech_time--; - if (being->speech_time == 0) { - free(being->speech); - being->speech = NULL; - } - } + // Tick the beings (gives them a sense of time) + being->tick(); + + being->drawSpeech(guiGraphics); beingIterator++; } -- cgit v1.2.3-70-g09d2