/**\brief Draws the radar. */ void Radar::Draw( Camera* camera, SpriteManager* sprites ) { short int radar_mid_x = RADAR_MIDDLE_X + Video::GetWidth() - 129; short int radar_mid_y = RADAR_MIDDLE_Y + 5; int radarSize; Coordinate focus = camera->GetFocusCoordinate(); /*if(largeMode) { if( visibility <= QUADRANTSIZE ) { Map* map = (Map*)UI::Search( "/Map/" ); assert(map); // large mode should only be on when there is a map. if(map) { map->SetCenter( focus ); map->SetScale( 300.0 / (2*visibility) ); } } return; }*/ list<Sprite*> *spriteList = sprites->GetSpritesNear(camera->GetFocusCoordinate(), (float)visibility); for( list<Sprite*>::const_iterator iter = spriteList->begin(); iter != spriteList->end(); iter++) { Coordinate blip; Sprite *sprite = *iter; // Calculate the blip coordinate for this sprite Coordinate wpos = sprite->GetWorldPosition(); WorldToBlip( focus, wpos, blip ); // Use the OpenGL Crop Rectangle to ensure that the blip is on the radar /* Convert to screen coords */ blip.SetX( blip.GetX() + radar_mid_x ); blip.SetY( blip.GetY() + radar_mid_y ); radarSize = int((sprite->GetRadarSize() / float(visibility)) * (RADAR_HEIGHT / 4.0)); if( radarSize >= 1 ) { if(sprite->GetID() == Hud::GetTarget() && Timer::GetTicks() % 1000 < 100) Video::DrawCircle( blip, radarSize, 2, WHITE ); else Video::DrawCircle( blip, radarSize, 1, sprite->GetRadarColor() ); } else { if(sprite->GetID() == Hud::GetTarget() && Timer::GetTicks() % 1000 < 100) Video::DrawCircle( blip, 1, 2, WHITE ); else Video::DrawPoint( blip, sprite->GetRadarColor() ); } } delete spriteList; }
/**\brief Draws the target. */ void Hud::DrawTarget( SpriteManager* sprites ) { Sprite* target = sprites->GetSpriteByID( targetID ); if(target != NULL) { int edge = (target->GetImage())->GetWidth() / 6; Coordinate targetScreenPosition = target->GetScreenPosition(); if(edge > 25) edge = 25; int x = targetScreenPosition.GetX(); int y = targetScreenPosition.GetY(); int r = target->GetRadarSize(); Color c = target->GetRadarColor(); if( (Timer::GetTicks() - timeTargeted) < OPTION(Uint32, "options/timing/target-zoom")) { r += Video::GetHalfHeight() - Video::GetHalfHeight()*(Timer::GetTicks()-timeTargeted)/OPTION(Uint32,"options/timing/target-zoom"); for( int i = 0; i < RETICLE_BLUR; i++ ) { c = c * .9f; edge += 3; r *= 1.1f; Video::DrawTarget(x,y,r,r,edge,c.r,c.g,c.b); } } else { Video::DrawTarget(x,y,r,r,edge,c.r,c.g,c.b); } } }
void Radar::Draw( SpriteManager &sprites ) { short int radar_mid_x = RADAR_MIDDLE_X + Video::GetWidth() - 129; short int radar_mid_y = RADAR_MIDDLE_Y + 5; int radarSize; const list<Sprite*>& spriteList = sprites.GetSprites(); for( list<Sprite*>::const_iterator iter = spriteList.begin(); iter != spriteList.end(); iter++) { Coordinate blip( -(RADAR_HEIGHT / 2.0), (RADAR_WIDTH / 2.0), (RADAR_HEIGHT / 2.0), -(RADAR_WIDTH / 2.0) ); Sprite *sprite = *iter; if( sprite->GetDrawOrder() == DRAW_ORDER_PLAYER ) continue; // Calculate the blip coordinate for this sprite Coordinate wpos = sprite->GetWorldPosition(); WorldToBlip( wpos, blip ); if( blip.ViolatesBoundary() == false ) { /* blip is on the radar */ /* Convert to screen coords */ blip.SetX( blip.GetX() + radar_mid_x ); blip.SetY( blip.GetY() + radar_mid_y ); radarSize = int((sprite->GetRadarSize() / float(visibility)) * (RADAR_HEIGHT/4.0)); Video::DrawCircle( blip, (radarSize>=1) ?radarSize: 1, 1, sprite->GetRadarColor() ); } } }
/**\brief Draws the radar. */ void Radar::Draw( void ) { short int radar_mid_x = RADAR_MIDDLE_X + Video::GetWidth() - 129; short int radar_mid_y = RADAR_MIDDLE_Y + 5; int radarSize; list<Sprite*> *spriteList = SpriteManager::Instance()->GetSpritesNear(Camera::Instance()->GetFocusCoordinate(), (float)visibility); for( list<Sprite*>::const_iterator iter = spriteList->begin(); iter != spriteList->end(); iter++) { Coordinate blip; Sprite *sprite = *iter; //if( sprite->GetDrawOrder() == DRAW_ORDER_PLAYER ) continue; // Calculate the blip coordinate for this sprite Coordinate wpos = sprite->GetWorldPosition(); WorldToBlip( wpos, blip ); // Use the OpenGL Crop Rectangle to ensure that the blip is on the radar /* Convert to screen coords */ blip.SetX( blip.GetX() + radar_mid_x ); blip.SetY( blip.GetY() + radar_mid_y ); radarSize = int((sprite->GetRadarSize() / float(visibility)) * (RADAR_HEIGHT/4.0)); if( radarSize >= 1 ) { if(sprite->GetID() == Hud::GetTarget() && Timer::GetTicks() % 1000 < 100) Video::DrawCircle( blip, radarSize, 2, WHITE ); else Video::DrawCircle( blip, radarSize, 1, sprite->GetRadarColor() ); } else { if(sprite->GetID() == Hud::GetTarget() && Timer::GetTicks() % 1000 < 100) Video::DrawCircle( blip, 1, 2, WHITE ); else Video::DrawPoint( blip, sprite->GetRadarColor() ); } } delete spriteList; }
/**\brief Draws the target. */ void Hud::DrawTarget( void ) { Sprite* target = SpriteManager::Instance()->GetSpriteByID( targetID ); if(target != NULL) { int x = target->GetWorldPosition().GetScreenX(); int y = target->GetWorldPosition().GetScreenY(); int r = target->GetRadarSize(); Color c = target->GetRadarColor(); if( Timer::GetTicks() - timeTargeted < OPTION(Uint32,"options/timing/target-zoom")) { r += Video::GetHalfHeight() - Video::GetHalfHeight()*(Timer::GetTicks()-timeTargeted)/OPTION(Uint32,"options/timing/target-zoom"); } Video::DrawTarget(x,y,r,r,5,c.r,c.g,c.b); } }
/**\brief Draws the radar. */ void Radar::Draw( void ) { short int radar_mid_x = RADAR_MIDDLE_X + Video::GetWidth() - 129; short int radar_mid_y = RADAR_MIDDLE_Y + 5; int radarSize; list<Sprite*> *spriteList = SpriteManager::Instance()->GetSpritesNear(Camera::Instance()->GetFocusCoordinate(), (float)visibility); for( list<Sprite*>::const_iterator iter = spriteList->begin(); iter != spriteList->end(); iter++) { Coordinate blip; Sprite *sprite = *iter; //if( sprite->GetDrawOrder() == DRAW_ORDER_PLAYER ) continue; // Calculate the blip coordinate for this sprite Coordinate wpos = sprite->GetWorldPosition(); WorldToBlip( wpos, blip ); if( blip.ViolatesBoundary( -(RADAR_HEIGHT / 2.0), (RADAR_WIDTH / 2.0), (RADAR_HEIGHT / 2.0), -(RADAR_WIDTH / 2.0) ) == false ) { /* blip is on the radar */ /* Convert to screen coords */ blip.SetX( blip.GetX() + radar_mid_x ); blip.SetY( blip.GetY() + radar_mid_y ); radarSize = int((sprite->GetRadarSize() / float(visibility)) * (RADAR_HEIGHT/4.0)); if( radarSize >= 1 ) { Video::DrawCircle( blip, radarSize, 1, sprite->GetRadarColor() ); } else { Video::DrawPoint( blip, sprite->GetRadarColor() ); } } } delete spriteList; }