SuperTuxKart
demo_world.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2012-2015 Joerg Henrichs
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 3
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 #ifndef HEADER_DEMO_WORLD_HPP
20 #define HEADER_DEMO_WORLD_HPP
21 
22 #include "modes/profile_world.hpp"
23 
24 class Kart;
25 
31 class DemoWorld : public ProfileWorld
32 {
33 private:
36  bool m_abort;
37 
40  static std::vector<std::string> m_demo_tracks;
41 
43  static int m_default_num_karts;
44 
46  static float m_max_idle_time;
47 
49  static float m_current_idle_time;
50 
52  static bool m_do_demo;
53 public:
54  DemoWorld();
55  virtual ~DemoWorld();
56  virtual bool isRaceOver() OVERRIDE;
57  virtual void enterRaceOverState() OVERRIDE;
58  // ------------------------------------------------------------------------
60  virtual std::string getInternalCode() const OVERRIDE { return "DEMO"; }
61  // ------------------------------------------------------------------------
62  virtual void update(int ticks) OVERRIDE { ProfileWorld::update(ticks); }
63  // ------------------------------------------------------------------------
64  static bool updateIdleTimeAndStartDemo(float dt);
65  // ------------------------------------------------------------------------
68  static void setNumLaps(unsigned int num_laps) { m_num_laps = num_laps; }
69  // ------------------------------------------------------------------------
71  static void setNumKarts(unsigned int num_karts)
72  {
73  m_default_num_karts = num_karts;
74  } // setNumKarts
75  // ------------------------------------------------------------------------
76  static void setTracks(const std::vector<std::string> &tracks);
77  // ------------------------------------------------------------------------
81  static void enableDemoMode(float time=1.0f) { m_max_idle_time = time; }
82  // ------------------------------------------------------------------------
84  static bool isDemoMode() { return m_do_demo; }
85  // ------------------------------------------------------------------------
87  static void resetIdleTime() { m_current_idle_time = 0; }
88  // ------------------------------------------------------------------------
90  void abortDemo() {m_abort = true; }
91 }; // DemoWorld
92 
93 #endif
void abortDemo()
Signals that the demo should be aborted.
Definition: demo_world.hpp:90
The main kart class.
Definition: kart.hpp:68
static void enableDemoMode(float time=1.0f)
Enables demo mode after the specified amount of time (default 1 second).
Definition: demo_world.hpp:81
virtual bool isRaceOver() OVERRIDE
The race is over if either the requested number of laps have been done or the requested time is over.
Definition: demo_world.cpp:82
virtual void update(int ticks)
Counts the number of frames.
Definition: profile_world.cpp:154
static bool m_do_demo
True if the next race is to be a demo race.
Definition: demo_world.hpp:52
bool m_abort
True if demo mode should be aborted, e.g.
Definition: demo_world.hpp:36
static bool updateIdleTimeAndStartDemo(float dt)
Updates the current idle time by dt.
Definition: demo_world.cpp:107
An implementation of World, used for profiling only.
Definition: profile_world.hpp:30
static void setNumLaps(unsigned int num_laps)
Sets the number of laps to use in demo mode.
Definition: demo_world.hpp:68
static int m_default_num_karts
Number of karts to use in demo mode.
Definition: demo_world.hpp:43
static void setNumKarts(unsigned int num_karts)
Sets the number of karts to use in demo mode.
Definition: demo_world.hpp:71
DemoWorld()
The constructor sets the number of (local) players to 0, since only AI karts are used.
Definition: demo_world.cpp:43
static bool isDemoMode()
Returns true if the menu detected enough idle time to run a demo.
Definition: demo_world.hpp:84
virtual void enterRaceOverState() OVERRIDE
This function is called when the race is finished, but end-of-race animations have still to be played...
Definition: demo_world.cpp:95
This class is used to show a demo of STK (e.g.
Definition: demo_world.hpp:31
virtual void update(int ticks) OVERRIDE
Counts the number of frames.
Definition: demo_world.hpp:62
static int m_num_laps
In laps based profiling: number of laps to run.
Definition: profile_world.hpp:73
static void resetIdleTime()
Resets the idle time to 0.
Definition: demo_world.hpp:87
static float m_max_idle_time
Idle time after which demo mode should be started.
Definition: demo_world.hpp:46
static std::vector< std::string > m_demo_tracks
The list of tracks to use for demo mode.
Definition: demo_world.hpp:40
virtual ~DemoWorld()
Destructor.
Definition: demo_world.cpp:63
static float m_current_idle_time
Used by the menu system to measure idle time.
Definition: demo_world.hpp:49
virtual std::string getInternalCode() const OVERRIDE
Returns identifier for this world.
Definition: demo_world.hpp:60
static void setTracks(const std::vector< std::string > &tracks)
Sets the list of tracks that is to be used.
Definition: demo_world.cpp:73