diff --git a/src/items/projectile_manager.cpp b/src/items/projectile_manager.cpp index 700faa30f..f44e220b1 100644 --- a/src/items/projectile_manager.cpp +++ b/src/items/projectile_manager.cpp @@ -219,8 +219,7 @@ bool ProjectileManager::projectileIsClose(const AbstractKart * const kart, float radius) { float r2 = radius * radius; - for (auto i = m_active_projectiles.begin(); i != m_active_projectiles.end(); - i++) + for (auto i = m_active_projectiles.begin(); i != m_active_projectiles.end(); i++) { if (!i->second->hasServerState()) continue; @@ -244,8 +243,7 @@ int ProjectileManager::getNearbyProjectileCount(const AbstractKart * const kart, { float r2 = radius * radius; int projectile_count = 0; - for (auto i = m_active_projectiles.begin(); i != m_active_projectiles.end(); - i++) + for (auto i = m_active_projectiles.begin(); i != m_active_projectiles.end(); i++) { if (!i->second->hasServerState()) continue; @@ -264,6 +262,20 @@ int ProjectileManager::getNearbyProjectileCount(const AbstractKart * const kart, return projectile_count; } // getNearbyProjectileCount +// ----------------------------------------------------------------------------- +std::vector ProjectileManager::getBasketballPositions() +{ + std::vector positions; + for (auto i = m_active_projectiles.begin(); i != m_active_projectiles.end(); i++) + { + if (!i->second->hasServerState()) + continue; + if (i->second->getType() == PowerupManager::POWERUP_RUBBERBALL) + positions.emplace_back(i->second->getXYZ()); + } // loop over projectiles + + return positions; +} // getBasketballPositions // ----------------------------------------------------------------------------- std::string ProjectileManager::getUniqueIdentity(AbstractKart* kart, PowerupManager::PowerupType t) diff --git a/src/items/projectile_manager.hpp b/src/items/projectile_manager.hpp index 57e42e831..52fca14f4 100644 --- a/src/items/projectile_manager.hpp +++ b/src/items/projectile_manager.hpp @@ -93,6 +93,8 @@ public: std::shared_ptr newProjectile(AbstractKart *kart, PowerupManager::PowerupType type); // ------------------------------------------------------------------------ + std::vector getBasketballPositions(); + // ------------------------------------------------------------------------ void addByUID(const std::string& uid, std::shared_ptr f) { m_active_projectiles[uid] = f; } // ------------------------------------------------------------------------ diff --git a/src/states_screens/race_gui.cpp b/src/states_screens/race_gui.cpp index 9a9cdc20b..ae164522b 100644 --- a/src/states_screens/race_gui.cpp +++ b/src/states_screens/race_gui.cpp @@ -41,6 +41,7 @@ using namespace irr; #include "guiengine/scalable_font.hpp" #include "io/file_manager.hpp" #include "items/powerup_manager.hpp" +#include "items/projectile_manager.hpp" #include "karts/abstract_kart.hpp" #include "karts/controller/controller.hpp" #include "karts/controller/spare_tire_ai.hpp" @@ -100,6 +101,7 @@ RaceGUI::RaceGUI() m_blue_flag = irr_driver->getTexture(FileManager::GUI_ICON, "blue_flag.png"); m_soccer_ball = irr_driver->getTexture(FileManager::GUI_ICON, "soccer_ball_normal.png"); m_heart_icon = irr_driver->getTexture(FileManager::GUI_ICON, "heart.png"); + m_basket_ball_icon = irr_driver->getTexture(FileManager::GUI_ICON, "rubber_ball-icon.png"); m_champion = irr_driver->getTexture(FileManager::GUI_ICON, "cup_gold.png"); } // RaceGUI @@ -672,7 +674,7 @@ void RaceGUI::drawGlobalMiniMap() bool has_teams = (ctf_world || soccer_world); - // Highlight the player icons with some backgorund image. + // Highlight the player icons with some background image. if ((has_teams || is_local) && m_icons_frame != NULL) { video::SColor color = kart->getKartProperties()->getColor(); @@ -721,6 +723,26 @@ void RaceGUI::drawGlobalMiniMap() } // for i basketballs = ProjectileManager::get()->getBasketballPositions(); + for(unsigned int i = 0; i != basketballs.size(); i++) + { + Vec3 draw_at; + track->mapPoint2MiniMap(basketballs[i], &draw_at); + + video::ITexture* icon = m_basket_ball_icon; + + core::rect source(core::position2di(0, 0), icon->getSize()); + int marker_half_size = m_minimap_player_size / 2; + core::rect position(m_map_left+(int)(draw_at.getX()-marker_half_size), + lower_y -(int)(draw_at.getY()+marker_half_size), + m_map_left+(int)(draw_at.getX()+marker_half_size), + lower_y -(int)(draw_at.getY()-marker_half_size)); + + draw2DImage(icon, position, source, NULL, NULL, true); + } + + // Draw the soccer ball icon if (soccer_world) { Vec3 draw_at; diff --git a/src/states_screens/race_gui.hpp b/src/states_screens/race_gui.hpp index d5430419e..0269d2c3a 100644 --- a/src/states_screens/race_gui.hpp +++ b/src/states_screens/race_gui.hpp @@ -99,6 +99,7 @@ private: irr::video::ITexture *m_blue_flag; irr::video::ITexture *m_soccer_ball; irr::video::ITexture *m_heart_icon; + irr::video::ITexture *m_basket_ball_icon; /** Texture for the hit limit icon*/ irr::video::ITexture* m_champion;