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 SFXBase;
29 class SFXBuffer;
30 class btTransform;
31 
32 #ifndef SERVER_ONLY
33 class ParticleEmitter;
34 #endif
35 
42 {
43 private:
44 
47 
48  bool m_sound_schedule;
49  bool m_has_started;
50  bool m_is_above_nitro_target;
51 
52 #ifndef SERVER_ONLY
53  std::unique_ptr<ParticleEmitter> m_sky_particles_emitter;
54 #endif
55 
59 
60  int m_last_crash;
61 
62  HandicapLevel m_handicap;
63 
64  SFXBase *m_wee_sound;
65  SFXBuffer *m_bzzt_sound;
66  SFXBuffer *m_ugh_sound;
67  SFXBuffer *m_grab_sound;
68  SFXBuffer *m_full_sound;
69  SFXBuffer *m_unfull_sound;
70 
71 
72  virtual void steer(int, int) OVERRIDE;
73  virtual void displayPenaltyWarning() OVERRIDE;
74  void nitroNotFullSound();
75 
76  void doCrashHaptics();
77  void setParticleEmitterPosition(const btTransform& t);
78 
79 public:
81  const int local_player_id,
82  HandicapLevel h);
84  void update (int ticks) OVERRIDE;
85  bool action (PlayerAction action, int value,
86  bool dry_run=false) OVERRIDE;
87  void initParticleEmitter();
88  virtual void handleZipper (bool play_sound) OVERRIDE;
89  void collectedItem (const ItemState &item,
90  float previous_energy=0) OVERRIDE;
91  virtual void setPosition (int p) OVERRIDE;
92  virtual void reset () OVERRIDE;
93  virtual void finishedRace (float time) OVERRIDE;
94  virtual void resetInputState () OVERRIDE;
95  virtual bool canGetAchievements() const OVERRIDE;
96 
97  virtual void crashed(const AbstractKart *k) OVERRIDE;
98  virtual void crashed(const Material *m) OVERRIDE;
99 
100  virtual void rumble(float strength_low, float strength_high, uint16_t duration) OVERRIDE;
101 
102  // ------------------------------------------------------------------------
103  virtual bool isPlayerController() const OVERRIDE {return true;}
104  // ------------------------------------------------------------------------
105  virtual bool isLocalPlayerController() const OVERRIDE {return true;}
106  // ------------------------------------------------------------------------
108  core::stringw getName(bool include_handicap_string = true) const OVERRIDE;
109 }; // LocalPlayerController
110 
111 #endif
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Contains the state information of an item, i.e.
Definition: item.hpp:53
PlayerKart manages control events from the player and moves them to the Kart.
Definition: local_player_controller.hpp:42
virtual void finishedRace(float time) OVERRIDE
Called when a kart finishes race.
Definition: local_player_controller.cpp:372
virtual bool isLocalPlayerController() const OVERRIDE
This function checks if this is a local player.
Definition: local_player_controller.hpp:105
StateManager::ActivePlayer * m_player
Stores the active player data structure.
Definition: local_player_controller.hpp:46
void collectedItem(const ItemState &item, float previous_energy=0) OVERRIDE
Called when a kart hits an item.
Definition: local_player_controller.cpp:409
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:172
virtual void steer(int, int) OVERRIDE
Handles steering for a player kart.
Definition: local_player_controller.cpp:226
virtual void handleZipper(bool play_sound) OVERRIDE
Called when a kart hits or uses a zipper.
Definition: local_player_controller.cpp:382
virtual void displayPenaltyWarning() OVERRIDE
Displays a penalty warning for player controlled karts.
Definition: local_player_controller.cpp:326
void update(int ticks) OVERRIDE
Updates the player kart, called once each timestep.
Definition: local_player_controller.cpp:248
virtual bool canGetAchievements() const OVERRIDE
Returns true if the player of this controller can collect achievements.
Definition: local_player_controller.cpp:457
int m_camera_index
The index of the camera attached to the kart for this controller.
Definition: local_player_controller.hpp:58
void nitroNotFullSound()
If the nitro level has gone under the nitro goal, play a bad effect sound.
Definition: local_player_controller.cpp:444
virtual void resetInputState() OVERRIDE
Resets the state of control keys.
Definition: local_player_controller.cpp:149
virtual bool isPlayerController() const OVERRIDE
This function checks if this player is not an AI, i.e.
Definition: local_player_controller.hpp:103
virtual void reset() OVERRIDE
Resets the player kart for a new or restarted race.
Definition: local_player_controller.cpp:136
core::stringw getName(bool include_handicap_string=true) const OVERRIDE
Returns the name of the player profile.
Definition: local_player_controller.cpp:464
virtual void setPosition(int p) OVERRIDE
Called just before the kart position is changed.
Definition: local_player_controller.cpp:346
Definition: material.hpp:48
manages smoke particle effects
Definition: particle_emitter.hpp:44
Definition: player_controller.hpp:28
The base class for sound effects.
Definition: sfx_base.hpp:43
The buffer (data) for one kind of sound effects.
Definition: sfx_buffer.hpp:44
Represents a player that is currently playing.
Definition: state_manager.hpp:76
PlayerAction
types of input events / what actions the players can do
Definition: input.hpp:117
HandicapLevel
Handicap per player.
Definition: remote_kart_info.hpp:43