diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-02-13 00:15:33 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-02-13 00:15:33 +0000 |
commit | 85f211ea50df2d48c0400b2a267808f798b524fa (patch) | |
tree | deb1a7ec15369e1b8b9def4a221548e87214d320 /src/graphic | |
parent | 4daa948c97c738ae102559635be3b89dc2b78dc4 (diff) | |
download | mana-85f211ea50df2d48c0400b2a267808f798b524fa.tar.gz mana-85f211ea50df2d48c0400b2a267808f798b524fa.tar.bz2 mana-85f211ea50df2d48c0400b2a267808f798b524fa.tar.xz mana-85f211ea50df2d48c0400b2a267808f798b524fa.zip |
New shorter and more flexible pathfinding implementation, which is hopefully
also more stable.
Diffstat (limited to 'src/graphic')
-rw-r--r-- | src/graphic/graphic.cpp | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp index bff5a29b..da18b109 100644 --- a/src/graphic/graphic.cpp +++ b/src/graphic/graphic.cpp @@ -118,7 +118,7 @@ int get_x_offset(Being *being) { if (being->action == WALK) { if (direction != NORTH && direction != SOUTH) { offset = being->frame + 1; - if (offset == 5)offset = 0; + if (offset == 5) offset = 0; offset *= 8; if (direction == WEST || direction == NW || direction == SW) { offset = -offset; @@ -486,6 +486,28 @@ void Engine::draw() #endif } } + +#ifdef __DEBUG + // Draw a debug path + PATH_NODE *debugPath = tiledMap.findPath( + player_node->x, player_node->y, + mouseX / 32 + camera_x, mouseY / 32 + camera_y); + + while (debugPath) + { + SDL_Rect destRect; + destRect.x = (debugPath->x - camera_x) * 32 - offset_x + 12; + destRect.y = (debugPath->y - camera_y) * 32 - offset_y + 12; + destRect.w = 8; + destRect.h = 8; + SDL_FillRect(screen, &destRect, SDL_MapRGB(screen->format, 255, 0, 0)); + + // Move to the next node + PATH_NODE *temp = debugPath->next; + delete debugPath; + debugPath = temp; + } +#endif // Draw player speech beingIterator = beings.begin(); @@ -526,8 +548,8 @@ void Engine::draw() gui->draw(); std::stringstream debugStream; - debugStream << "[" << fps << " fps] ";// << - // (mouse_x / 32 + camera_x) << ", " << (mouse_y / 32 + camera_y); + debugStream << "[" << fps << " fps] " << + (mouseX / 32 + camera_x) << ", " << (mouseY / 32 + camera_y); debugInfo->setCaption(debugStream.str()); debugInfo->adjustSize(); } |