From d283db70abe904fddd8aefbd52b35d6e066dd98f Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Tue, 14 Jun 2005 14:24:28 +0000 Subject: Added background to minimap. Only used in Tonori Desert map for now, and its style is up for discussion. --- src/engine.cpp | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) (limited to 'src/engine.cpp') diff --git a/src/engine.cpp b/src/engine.cpp index 9c39b3aa..bca79219 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -137,7 +137,8 @@ int get_y_offset(Being *being) return offset; } -Engine::Engine() +Engine::Engine(): + mCurrentMap(NULL) { // Initializes GUI debugInfo = new gcn::Label(); @@ -265,6 +266,17 @@ Engine::~Engine() delete itemset; } +Map *Engine::getCurrentMap() +{ + return mCurrentMap; +} + +void Engine::setCurrentMap(Map *newMap) +{ + mCurrentMap = newMap; + minimap->setMap(mCurrentMap); +} + void Engine::logic() { // Update beings @@ -309,9 +321,10 @@ void Engine::draw() frame++; // Draw tiles below nodes - if (tiledMap) { - tiledMap->draw(guiGraphics, map_x, map_y, 0); - tiledMap->draw(guiGraphics, map_x, map_y, 1); + if (mCurrentMap != NULL) + { + mCurrentMap->draw(guiGraphics, map_x, map_y, 0); + mCurrentMap->draw(guiGraphics, map_x, map_y, 1); } // Draw items @@ -439,15 +452,16 @@ void Engine::draw() } // Draw tiles below nodes - if (tiledMap) { - tiledMap->draw(guiGraphics, map_x, map_y, 2); + if (mCurrentMap != NULL) + { + mCurrentMap->draw(guiGraphics, map_x, map_y, 2); } // Find a path from the player to the mouse, and draw it. This is for debug // purposes. - if (displayPathToMouse) + if (displayPathToMouse && mCurrentMap != NULL) { - std::list debugPath = tiledMap->findPath( + std::list debugPath = mCurrentMap->findPath( player_node->x, player_node->y, mouseX / 32 + camera_x, mouseY / 32 + camera_y); @@ -461,7 +475,7 @@ void Engine::draw() guiGraphics->setColor(gcn::Color(255, 0, 0)); guiGraphics->fillRectangle(gcn::Rectangle(squareX, squareY, 8, 8)); - MetaTile *tile = tiledMap->getMetaTile(node.x, node.y); + MetaTile *tile = mCurrentMap->getMetaTile(node.x, node.y); std::stringstream cost; cost << tile->Gcost; @@ -492,8 +506,14 @@ void Engine::draw() std::stringstream debugStream; debugStream << "[" << fps << " fps] " << (mouseX / 32 + camera_x) << ", " << (mouseY / 32 + camera_y); - debugStream << " [music: " << tiledMap->getProperty("music") << "]"; - debugStream << " [minimap: " << tiledMap->getProperty("minimap") << "]"; + + if (mCurrentMap != NULL) + { + debugStream + << " [music: " << mCurrentMap->getProperty("music") << "]" + << " [minimap: " << mCurrentMap->getProperty("minimap") << "]"; + } + debugInfo->setCaption(debugStream.str()); debugInfo->adjustSize(); } -- cgit v1.2.3-60-g2f50