SuperTuxKart
follow_the_leader.hpp
1 // SuperTuxKart - a fun racing game with go-kart
2 // Copyright (C) 2004-2015 SuperTuxKart-Team
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 3
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 
18 #ifndef _follow_the_leader_hpp_
19 #define _follow_the_leader_hpp_
20 
21 #define LEADER_HIT_TIME 5.0f
22 
23 #include "modes/linear_world.hpp"
24 
30 {
31 private:
32  // time till elimination in follow leader
33  std::vector<float> m_leader_intervals;
34 
35  // Number of rescue/hit endured by the leader since the previous kart elimination
36  unsigned int m_leader_hit_count;
37 
40 
44 public:
45 
47  virtual ~FollowTheLeaderRace();
48 
49  // clock events
50  virtual void countdownReachedZero() OVERRIDE;
51  virtual int getScoreForPosition(int p) OVERRIDE;
52 
53  // overriding World methods
54  virtual void reset(bool restart=false) OVERRIDE;
55  virtual const std::string& getIdent() const OVERRIDE;
56  virtual const btTransform &getStartTransform(int index) OVERRIDE;
57  virtual void getKartsDisplayInfo(
58  std::vector<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE;
59  virtual void init() OVERRIDE;
60  virtual void terminateRace() OVERRIDE;
61  virtual bool isRaceOver() OVERRIDE;
62  // ------------------------------------------------------------------------
64  virtual bool raceHasLaps() OVERRIDE { return false; }
65  // ------------------------------------------------------------------------
67  virtual bool useFastMusicNearEnd() const OVERRIDE { return false; }
68 
69  bool isLeader(int kart_id) { return (kart_id == 0); }
70  void leaderHit();
71  // For now, use a similar countdown change as with leaderHit
72  void leaderRescued() { leaderHit(); }
73 }; // FollowTheLeader
74 
75 
76 #endif
An implementation of World, based on LinearWorld, to provide the Follow-the-leader game mode.
Definition: follow_the_leader.hpp:30
virtual int getScoreForPosition(int p) OVERRIDE
Returns the number of points for a kart at a specified position.
Definition: follow_the_leader.cpp:100
void leaderHit()
If the leader kart is hit, increase the delay to the next elimination.
Definition: follow_the_leader.cpp:230
virtual const std::string & getIdent() const OVERRIDE
Returns the internal identifier for this kind of race.
Definition: follow_the_leader.cpp:288
virtual bool isRaceOver() OVERRIDE
The follow the leader race is over if there is only one kart left (plus the leader),...
Definition: follow_the_leader.cpp:207
virtual void countdownReachedZero() OVERRIDE
Called when a kart must be eliminated.
Definition: follow_the_leader.cpp:125
virtual void init() OVERRIDE
Called immediately after the constructor.
Definition: follow_the_leader.cpp:57
virtual bool raceHasLaps() OVERRIDE
Returns if this type of race has laps.
Definition: follow_the_leader.hpp:64
virtual void terminateRace() OVERRIDE
Called at the end of a race.
Definition: follow_the_leader.cpp:244
virtual void reset(bool restart=false) OVERRIDE
Called just before a race is started.
Definition: follow_the_leader.cpp:80
virtual const btTransform & getStartTransform(int index) OVERRIDE
Returns the start coordinates for a kart with a given index.
Definition: follow_the_leader.cpp:111
virtual void getKartsDisplayInfo(std::vector< RaceGUIBase::KartIconDisplayInfo > *info) OVERRIDE
Sets the title for all karts that is displayed in the icon list.
Definition: follow_the_leader.cpp:297
virtual bool useFastMusicNearEnd() const OVERRIDE
Returns if faster music should be used at the end.
Definition: follow_the_leader.hpp:67
float m_last_eliminated_time
Time the last kart was eliminated.
Definition: follow_the_leader.hpp:43
float m_is_over_delay
A timer used before terminating the race.
Definition: follow_the_leader.hpp:39
Definition: linear_world.hpp:36
An abstract base class for the two race guis (race_gui and race_result gui)
Definition: race_gui_base.hpp:50