Initial Score display. (Using only the first two karts)
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/soccer@13142 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
59c1fccef2
commit
c22941d354
@ -93,37 +93,45 @@ void SoccerWorld::update(float dt)
|
|||||||
|
|
||||||
void SoccerWorld::onCheckGoalTriggered(bool first_goal)
|
void SoccerWorld::onCheckGoalTriggered(bool first_goal)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
if(m_can_score_points)
|
if(m_can_score_points){
|
||||||
printf("*** GOOOOOOOOOAAAAAAALLLLLL!!!! (team: %d) ***\n", first_goal ? 0 : 1);
|
printf("*** GOOOOOOOOOAAAAAAALLLLLL!!!! (team: %d) ***\n", first_goal ? 0 : 1);
|
||||||
|
m_team_goals[first_goal]++;
|
||||||
//m_check_goals_enabled = false; // TODO: remove?
|
printf("Score:\nTeam One %d : %d Team Two\n", m_team_goals[0], m_team_goals[1]);
|
||||||
|
}
|
||||||
// Reset original positions for the soccer balls
|
|
||||||
TrackObjectManager* tom = getTrack()->getTrackObjectManager();
|
//m_check_goals_enabled = false; // TODO: remove?
|
||||||
assert(tom);
|
|
||||||
|
// Reset original positions for the soccer balls
|
||||||
PtrVector<TrackObject>& objects = tom->getObjects();
|
TrackObjectManager* tom = getTrack()->getTrackObjectManager();
|
||||||
for(int i=0; i<objects.size(); i++)
|
assert(tom);
|
||||||
{
|
|
||||||
TrackObject* obj = objects.get(i);
|
PtrVector<TrackObject>& objects = tom->getObjects();
|
||||||
if(!obj->isSoccerBall())
|
for(int i=0; i<objects.size(); i++)
|
||||||
continue;
|
{
|
||||||
|
TrackObject* obj = objects.get(i);
|
||||||
obj->reset();
|
if(!obj->isSoccerBall())
|
||||||
}
|
continue;
|
||||||
|
|
||||||
//for(int i=0 ; i < getNumKarts() ; i++
|
obj->reset();
|
||||||
|
obj->getPhysics()->reset();
|
||||||
/*if(World::getWorld()->getTrack()->isAutoRescueEnabled() &&
|
}
|
||||||
!getKartAnimation() && fabs(getRoll())>60*DEGREE_TO_RAD &&
|
|
||||||
fabs(getSpeed())<3.0f )
|
//Resetting the ball triggers the goal check line one more time.
|
||||||
{
|
//This ensures that only one goal is counted, and the second is ignored.
|
||||||
new RescueAnimation(this, true);
|
m_can_score_points = !m_can_score_points;
|
||||||
}*/
|
|
||||||
|
//for(int i=0 ; i < getNumKarts() ; i++
|
||||||
// TODO: rescue the karts
|
|
||||||
// TODO: score a point
|
/*if(World::getWorld()->getTrack()->isAutoRescueEnabled() &&
|
||||||
|
!getKartAnimation() && fabs(getRoll())>60*DEGREE_TO_RAD &&
|
||||||
|
fabs(getSpeed())<3.0f )
|
||||||
|
{
|
||||||
|
new RescueAnimation(this, true);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// TODO: rescue the karts
|
||||||
|
// TODO: score a point
|
||||||
} // onCheckGoalTriggered
|
} // onCheckGoalTriggered
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -284,8 +292,6 @@ void SoccerWorld::initKartList()
|
|||||||
m_karts[n]->setPosition(-1);
|
m_karts[n]->setPosition(-1);
|
||||||
}
|
}
|
||||||
// TODO: remove
|
// TODO: remove
|
||||||
/*
|
|
||||||
const unsigned int kart_amount = m_karts.size();
|
|
||||||
|
|
||||||
int team_karts_amount[NB_SOCCER_TEAMS];
|
int team_karts_amount[NB_SOCCER_TEAMS];
|
||||||
memset(team_karts_amount, 0, sizeof(team_karts_amount));
|
memset(team_karts_amount, 0, sizeof(team_karts_amount));
|
||||||
@ -296,10 +302,11 @@ void SoccerWorld::initKartList()
|
|||||||
SoccerTeam round_robin_team = SOCCER_TEAM_RED;
|
SoccerTeam round_robin_team = SOCCER_TEAM_RED;
|
||||||
for(unsigned int n=0; n<kart_amount; n++)
|
for(unsigned int n=0; n<kart_amount; n++)
|
||||||
{
|
{
|
||||||
if(m_karts[n]->getSoccerTeam() == SOCCER_TEAM_NONE)
|
if(race_manager->getLocalKartInfo(n).getSoccerTeam() == SOCCER_TEAM_NONE)
|
||||||
m_karts[n]->setSoccerTeam(round_robin_team);
|
race_manager->setLocalKartSoccerTeam(
|
||||||
|
race_manager->getLocalKartInfo(n).getLocalPlayerId(),round_robin_team);
|
||||||
|
|
||||||
team_karts_amount[m_karts[n]->getSoccerTeam()]++;
|
team_karts_amount[race_manager->getLocalKartInfo(n).getSoccerTeam()]++;
|
||||||
|
|
||||||
round_robin_team = (round_robin_team==SOCCER_TEAM_RED ?
|
round_robin_team = (round_robin_team==SOCCER_TEAM_RED ?
|
||||||
SOCCER_TEAM_BLUE : SOCCER_TEAM_RED);
|
SOCCER_TEAM_BLUE : SOCCER_TEAM_RED);
|
||||||
@ -315,9 +322,13 @@ void SoccerWorld::initKartList()
|
|||||||
// Set kart positions, ordering them by team
|
// Set kart positions, ordering them by team
|
||||||
for(unsigned int n=0; n<kart_amount; n++)
|
for(unsigned int n=0; n<kart_amount; n++)
|
||||||
{
|
{
|
||||||
SoccerTeam team = m_karts[n]->getSoccerTeam();
|
|
||||||
|
SoccerTeam team = race_manager->getLocalKartInfo(n).getSoccerTeam();
|
||||||
m_karts[n]->setPosition(team_cur_position[team]);
|
m_karts[n]->setPosition(team_cur_position[team]);
|
||||||
team_cur_position[team]++;
|
team_cur_position[team]++;
|
||||||
}// next kart
|
}// next kart
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
int SoccerWorld::getScore(unsigned int i){
|
||||||
|
return m_team_goals[i];
|
||||||
|
}
|
@ -45,6 +45,9 @@ private:
|
|||||||
/** Whether or not goals can be scored (they are disabled when a point is scored
|
/** Whether or not goals can be scored (they are disabled when a point is scored
|
||||||
and re-enabled when the next game can be played)*/
|
and re-enabled when the next game can be played)*/
|
||||||
bool m_can_score_points;
|
bool m_can_score_points;
|
||||||
|
|
||||||
|
/** Team karts */
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -63,6 +66,7 @@ public:
|
|||||||
virtual bool useFastMusicNearEnd() const { return false; }
|
virtual bool useFastMusicNearEnd() const { return false; }
|
||||||
virtual void getKartsDisplayInfo(
|
virtual void getKartsDisplayInfo(
|
||||||
std::vector<RaceGUIBase::KartIconDisplayInfo> *info);
|
std::vector<RaceGUIBase::KartIconDisplayInfo> *info);
|
||||||
|
int getScore(unsigned int i);
|
||||||
virtual bool raceHasLaps(){ return false; }
|
virtual bool raceHasLaps(){ return false; }
|
||||||
virtual void moveKartAfterRescue(AbstractKart* kart);
|
virtual void moveKartAfterRescue(AbstractKart* kart);
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public:
|
|||||||
void setHostId(int id) { m_host_id = id; }
|
void setHostId(int id) { m_host_id = id; }
|
||||||
void setLocalPlayerId(int id) { m_local_player_id = id; }
|
void setLocalPlayerId(int id) { m_local_player_id = id; }
|
||||||
void setGlobalPlayerId(int id) { m_global_player_id = id; }
|
void setGlobalPlayerId(int id) { m_global_player_id = id; }
|
||||||
void setSoccerTeam(SoccerTeam team) { m_soccer_team = team; }
|
const void setSoccerTeam(SoccerTeam team) { m_soccer_team = team; }
|
||||||
|
|
||||||
int getHostId() const { return m_host_id; }
|
int getHostId() const { return m_host_id; }
|
||||||
int getLocalPlayerId() const { return m_local_player_id; }
|
int getLocalPlayerId() const { return m_local_player_id; }
|
||||||
|
@ -44,6 +44,7 @@ using namespace irr;
|
|||||||
#include "modes/follow_the_leader.hpp"
|
#include "modes/follow_the_leader.hpp"
|
||||||
#include "modes/linear_world.hpp"
|
#include "modes/linear_world.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
|
#include "modes/soccer_world.hpp"
|
||||||
#include "race/race_manager.hpp"
|
#include "race/race_manager.hpp"
|
||||||
#include "tracks/track.hpp"
|
#include "tracks/track.hpp"
|
||||||
#include "utils/constants.hpp"
|
#include "utils/constants.hpp"
|
||||||
@ -177,6 +178,8 @@ void RaceGUI::renderGlobal(float dt)
|
|||||||
|
|
||||||
drawGlobalMiniMap();
|
drawGlobalMiniMap();
|
||||||
|
|
||||||
|
if(world->getTrack()->isSoccer()) drawScores();
|
||||||
|
|
||||||
if (!m_is_tutorial) drawGlobalPlayerIcons(m_map_height);
|
if (!m_is_tutorial) drawGlobalPlayerIcons(m_map_height);
|
||||||
} // renderGlobal
|
} // renderGlobal
|
||||||
|
|
||||||
@ -211,6 +214,37 @@ void RaceGUI::renderPlayerView(const Camera *camera, float dt)
|
|||||||
RaceGUIBase::renderPlayerView(camera, dt);
|
RaceGUIBase::renderPlayerView(camera, dt);
|
||||||
} // renderPlayerView
|
} // renderPlayerView
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void RaceGUI::drawScores()
|
||||||
|
{
|
||||||
|
SoccerWorld* soccerWorld = (SoccerWorld*)World::getWorld();
|
||||||
|
int offsetY = 5;
|
||||||
|
int offsetX = 5;
|
||||||
|
gui::ScalableFont* font = GUIEngine::getFont();
|
||||||
|
static video::SColor color = video::SColor(255,255,255,255);
|
||||||
|
|
||||||
|
//Draw kart icons above score(denoting teams)
|
||||||
|
for(unsigned int i=0; i<soccerWorld->getNumKarts(); i++){
|
||||||
|
core::rect<s32> source(i*m_marker_rendered_size, 0,
|
||||||
|
(i+1)*m_marker_rendered_size,m_marker_rendered_size);
|
||||||
|
core::recti position(offsetX, offsetY,
|
||||||
|
offsetX + 2*m_marker_player_size, offsetY + 2*m_marker_player_size);
|
||||||
|
irr_driver->getVideoDriver()->draw2DImage(m_marker, position, source,
|
||||||
|
NULL, NULL, true);
|
||||||
|
core::stringw score = StringUtils::toWString(soccerWorld->getScore(i));
|
||||||
|
int stringWidth =
|
||||||
|
GUIEngine::getFont()->getDimension(score.c_str()).Width;
|
||||||
|
int stringHeight =
|
||||||
|
GUIEngine::getFont()->getDimension(score.c_str()).Height;
|
||||||
|
core::recti pos(position.UpperLeftCorner.X + 5,
|
||||||
|
position.LowerRightCorner.Y + offsetY,
|
||||||
|
position.LowerRightCorner.X,
|
||||||
|
position.LowerRightCorner.Y + stringHeight);
|
||||||
|
|
||||||
|
font->draw(score.c_str(),pos,color);
|
||||||
|
offsetX += position.LowerRightCorner.X;
|
||||||
|
}
|
||||||
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/** Displays the racing time on the screen.s
|
/** Displays the racing time on the screen.s
|
||||||
*/
|
*/
|
||||||
|
@ -105,6 +105,8 @@ private:
|
|||||||
/** Display items that are shown once only (for all karts). */
|
/** Display items that are shown once only (for all karts). */
|
||||||
void drawGlobalMiniMap ();
|
void drawGlobalMiniMap ();
|
||||||
void drawGlobalTimer ();
|
void drawGlobalTimer ();
|
||||||
|
void drawScores();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user