SuperTuxKart
local_player_controller.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2004-2015 Steve Baker <sjbaker1@airmail.net>
4 // Copyright (C) 2006-2015 Joerg Henrichs, Steve Baker
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 3
9 // of the License, or (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 
20 
21 #ifndef HEADER_LOCAL_PLAYER_CONTROLLER_HPP
22 #define HEADER_LOCAL_PLAYER_CONTROLLER_HPP
23 
24 #include "karts/controller/player_controller.hpp"
25 #include <memory>
26 
27 class AbstractKart;
28 class ParticleEmitter;
29 class SFXBase;
30 class SFXBuffer;
31 
38 {
39 private:
40 
43 
44  bool m_sound_schedule;
45  bool m_has_started;
46  bool m_is_above_nitro_target;
47 
48  std::unique_ptr<ParticleEmitter> m_sky_particles_emitter;
49 
53 
54  int m_last_crash;
55 
56  HandicapLevel m_handicap;
57 
58  SFXBase *m_wee_sound;
59  SFXBuffer *m_bzzt_sound;
60  SFXBuffer *m_ugh_sound;
61  SFXBuffer *m_grab_sound;
62  SFXBuffer *m_full_sound;
63  SFXBuffer *m_unfull_sound;
64 
65 
66  virtual void steer(int, int) OVERRIDE;
67  virtual void displayPenaltyWarning() OVERRIDE;
68  void nitroNotFullSound();
69 
70  void doCrashHaptics();
71 
72 public:
74  const int local_player_id,
75  HandicapLevel h);
77  void update (int ticks) OVERRIDE;
78  bool action (PlayerAction action, int value,
79  bool dry_run=false) OVERRIDE;
80  void initParticleEmitter();
81  virtual void handleZipper (bool play_sound) OVERRIDE;
82  void collectedItem (const ItemState &item,
83  float previous_energy=0) OVERRIDE;
84  virtual void setPosition (int p) OVERRIDE;
85  virtual void reset () OVERRIDE;
86  virtual void finishedRace (float time) OVERRIDE;
87  virtual void resetInputState () OVERRIDE;
88  virtual bool canGetAchievements() const OVERRIDE;
89 
90  virtual void crashed(const AbstractKart *k) OVERRIDE;
91  virtual void crashed(const Material *m) OVERRIDE;
92 
93  virtual void rumble(float strength_low, float strength_high, uint16_t duration) OVERRIDE;
94 
95  // ------------------------------------------------------------------------
96  virtual bool isPlayerController() const OVERRIDE {return true;}
97  // ------------------------------------------------------------------------
98  virtual bool isLocalPlayerController() const OVERRIDE {return true;}
99  // ------------------------------------------------------------------------
101  core::stringw getName(bool include_handicap_string = true) const OVERRIDE;
102 
103 }; // LocalPlayerController
104 
105 #endif
PlayerKart manages control events from the player and moves them to the Kart.
Definition: local_player_controller.hpp:37
HandicapLevel
Handicap per player.
Definition: remote_kart_info.hpp:39
Represents a player that is currently playing.
Definition: state_manager.hpp:75
Definition: script_track.cpp:471
virtual void displayPenaltyWarning() OVERRIDE
Displays a penalty warning for player controlled karts.
Definition: local_player_controller.cpp:307
virtual bool canGetAchievements() const OVERRIDE
Returns true if the player of this controller can collect achievements.
Definition: local_player_controller.cpp:438
PlayerAction
types of input events / what actions the players can do
Definition: input.hpp:116
virtual void handleZipper(bool play_sound) OVERRIDE
Called when a kart hits or uses a zipper.
Definition: local_player_controller.cpp:363
virtual void reset() OVERRIDE
Resets the player kart for a new or restarted race.
Definition: local_player_controller.cpp:133
The buffer (data) for one kind of sound effects.
Definition: sfx_buffer.hpp:43
void update(int ticks) OVERRIDE
Updates the player kart, called once each timestep.
Definition: local_player_controller.cpp:245
bool action(PlayerAction action, int value, bool dry_run=false) OVERRIDE
This function interprets a kart action and value, and set the corresponding entries in the kart contr...
Definition: local_player_controller.cpp:169
virtual void setPosition(int p) OVERRIDE
Called just before the kart position is changed.
Definition: local_player_controller.cpp:327
virtual void finishedRace(float time) OVERRIDE
Called when a kart finishes race.
Definition: local_player_controller.cpp:353
virtual bool isPlayerController() const OVERRIDE
This function checks if this player is not an AI, i.e.
Definition: local_player_controller.hpp:96
void collectedItem(const ItemState &item, float previous_energy=0) OVERRIDE
Called when a kart hits an item.
Definition: local_player_controller.cpp:390
core::stringw getName(bool include_handicap_string=true) const OVERRIDE
Returns the name of the player profile.
Definition: local_player_controller.cpp:445
int m_camera_index
The index of the camera attached to the kart for this controller.
Definition: local_player_controller.hpp:52
StateManager::ActivePlayer * m_player
Stores the active player data structure.
Definition: local_player_controller.hpp:42
Definition: material.hpp:47
virtual bool isLocalPlayerController() const OVERRIDE
This function checks if this is a local player.
Definition: local_player_controller.hpp:98
virtual void steer(int, int) OVERRIDE
Handles steering for a player kart.
Definition: local_player_controller.cpp:223
The base class for sound effects.
Definition: sfx_base.hpp:42
void nitroNotFullSound()
If the nitro level has gone under the nitro goal, play a bad effect sound.
Definition: local_player_controller.cpp:425
Contains the state information of an item, i.e.
Definition: item.hpp:52
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61
Definition: player_controller.hpp:27
virtual void resetInputState() OVERRIDE
Resets the state of control keys.
Definition: local_player_controller.cpp:146