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