Kart positions fixed. Karts on the same team appear on the same side.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/soccer@13318 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
yasin-ghannam 2013-07-22 17:50:39 +00:00
parent d314ee2d0d
commit 88b6b4b5c4
3 changed files with 139 additions and 85 deletions

View File

@ -23,9 +23,11 @@
#include "audio/music_manager.hpp"
#include "io/file_manager.hpp"
#include "karts/abstract_kart.hpp"
#include "karts/kart.hpp"
#include "karts/kart_model.hpp"
#include "karts/kart_properties.hpp"
#include "karts/rescue_animation.hpp"
#include "karts/controller/player_controller.hpp"
#include "physics/physics.hpp"
#include "states_screens/race_gui_base.hpp"
#include "tracks/track.hpp"
@ -348,4 +350,48 @@ void SoccerWorld::initKartList()
//-----------------------------------------------------------------------------
int SoccerWorld::getScore(unsigned int i){
return m_team_goals[i];
}
}
//-----------------------------------------------------------------------------
AbstractKart *SoccerWorld::createKart(const std::string &kart_ident, int index,
int local_player_id, int global_player_id,
RaceManager::KartType kart_type)
{
int posIndex = index;
if(race_manager->getLocalKartInfo(index).getSoccerTeam() == SOCCER_TEAM_RED){
if(index % 2 != 0) posIndex += 1;
}
else if(race_manager->getLocalKartInfo(index).getSoccerTeam() == SOCCER_TEAM_BLUE){
if(index % 2 != 1) posIndex += 1;
}
int position = index+1;
btTransform init_pos = m_track->getStartTransform(posIndex);
AbstractKart *new_kart = new Kart(kart_ident, index, position, init_pos);
new_kart->init(race_manager->getKartType(index));
Controller *controller = NULL;
switch(kart_type)
{
case RaceManager::KT_PLAYER:
controller = new PlayerController(new_kart,
StateManager::get()->getActivePlayer(local_player_id),
local_player_id);
m_num_players ++;
break;
case RaceManager::KT_NETWORK_PLAYER:
break; // Avoid compiler warning about enum not handled.
//controller = new NetworkController(kart_ident, position, init_pos,
// global_player_id);
//m_num_players++;
//break;
case RaceManager::KT_AI:
controller = loadAIController(new_kart);
break;
case RaceManager::KT_GHOST:
break;
case RaceManager::KT_LEADER:
break;
}
new_kart->setController(controller);
return new_kart;
} // createKart

View File

@ -1,84 +1,91 @@
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2004 SuperTuxKart-Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SOCCER_WORLD_HPP
#define SOCCER_WORLD_HPP
#include "modes/world_with_rank.hpp"
#include "states_screens/race_gui_base.hpp"
#include "karts/abstract_kart.hpp"
#include <IMesh.h>
#include <string>
#define CLEAR_SPAWN_RANGE 5
class PhysicalObject;
/**
* \brief An implementation of World, to provide the soccer game mode
* \ingroup modes
*/
class SoccerWorld : public WorldWithRank
{
private:
/** Number of goals each team scored
*/
int m_team_goals[NB_SOCCER_TEAMS];
/** 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)*/
bool m_can_score_points;
/** Team karts */
public:
SoccerWorld();
virtual ~SoccerWorld() {}
virtual void init();
// clock events
virtual bool isRaceOver();
virtual void terminateRace();
// overriding World methods
virtual void reset();
virtual bool useFastMusicNearEnd() const { return false; }
virtual void getKartsDisplayInfo(
std::vector<RaceGUIBase::KartIconDisplayInfo> *info);
int getScore(unsigned int i);
virtual bool raceHasLaps(){ return false; }
virtual void moveKartAfterRescue(AbstractKart* kart);
virtual const std::string& getIdent() const;
virtual void update(float dt);
void onCheckGoalTriggered(bool first_goal);
private:
void initKartList();
}; // SoccerWorld
#endif
//
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2004 SuperTuxKart-Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SOCCER_WORLD_HPP
#define SOCCER_WORLD_HPP
#include "modes/world_with_rank.hpp"
#include "states_screens/race_gui_base.hpp"
#include "karts/abstract_kart.hpp"
#include <IMesh.h>
#include <string>
#define CLEAR_SPAWN_RANGE 5
class PhysicalObject;
class AbstractKart;
class Controller;
/**
* \brief An implementation of World, to provide the soccer game mode
* \ingroup modes
*/
class SoccerWorld : public WorldWithRank
{
private:
/** Number of goals each team scored
*/
int m_team_goals[NB_SOCCER_TEAMS];
/** 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)*/
bool m_can_score_points;
/** Team karts */
public:
SoccerWorld();
virtual ~SoccerWorld() {}
virtual void init();
// clock events
virtual bool isRaceOver();
virtual void terminateRace();
// overriding World methods
virtual void reset();
virtual bool useFastMusicNearEnd() const { return false; }
virtual void getKartsDisplayInfo(
std::vector<RaceGUIBase::KartIconDisplayInfo> *info);
int getScore(unsigned int i);
virtual bool raceHasLaps(){ return false; }
virtual void moveKartAfterRescue(AbstractKart* kart);
virtual const std::string& getIdent() const;
virtual void update(float dt);
void onCheckGoalTriggered(bool first_goal);
private:
void initKartList();
protected:
virtual AbstractKart *createKart(const std::string &kart_ident, int index,
int local_player_id, int global_player_id,
RaceManager::KartType type);
}; // SoccerWorld
#endif

View File

@ -66,6 +66,7 @@ public:
void endSetKartPositions();
AbstractKart* getKartAtPosition(unsigned int p) const;
}; // WorldWithRank
#endif