SuperTuxKart
Loading...
Searching...
No Matches
player_controller.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2004-2015 Steve Baker <sjbaker1@airmail.net>
3// Copyright (C) 2006-2015 Joerg Henrichs, Steve Baker
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_PLAYER_CONTROLLER_HPP
20#define HEADER_PLAYER_CONTROLLER_HPP
21
22#include "karts/controller/controller.hpp"
23
24class AbstractKart;
25class Player;
26
28{
29friend class KartRewinder;
30protected:
31 int m_steer_val, m_steer_val_l, m_steer_val_r;
32 uint16_t m_prev_accel;
33 bool m_prev_brake;
34 bool m_prev_nitro;
35
36 int m_penalty_ticks;
37
38 virtual void steer(int ticks, int steer_val);
39
40public:
42 virtual ~PlayerController ();
43 virtual void update (int ticks) OVERRIDE;
44 virtual bool action (PlayerAction action, int value,
45 bool dry_run = false ) OVERRIDE;
46 virtual void actionFromNetwork(PlayerAction action, int value,
47 int value_l, int value_r);
48 virtual void skidBonusTriggered() OVERRIDE;
49 virtual void reset () OVERRIDE;
50 virtual void handleZipper(bool play_sound) OVERRIDE;
51 virtual void resetInputState();
52 virtual bool saveState(BareNetworkString *buffer) const OVERRIDE;
53 virtual void rewindTo(BareNetworkString *buffer) OVERRIDE;
54 // ------------------------------------------------------------------------
55 virtual void collectedItem(const ItemState &item,
56 float previous_energy=0 ) OVERRIDE { };
57 // ------------------------------------------------------------------------
58 virtual bool isPlayerController() const OVERRIDE { return true; }
59 // ------------------------------------------------------------------------
60 virtual bool isLocalPlayerController() const OVERRIDE { return true; }
61 // ------------------------------------------------------------------------
63 virtual void setPosition(int p) OVERRIDE
64 {
65 } // setPosition
66 // ------------------------------------------------------------------------
67 virtual void crashed(const AbstractKart *k) OVERRIDE
68 {
69 } // crashed(AbstractKart)
70 // ------------------------------------------------------------------------
71 virtual void crashed(const Material *m) OVERRIDE
72 {
73 } // crashed(Material)
74 // ------------------------------------------------------------------------
77 virtual void newLap(int lap) OVERRIDE
78 {
79 }
80 // ------------------------------------------------------------------------
82 virtual bool disableSlipstreamBonus() const OVERRIDE
83 {
84 return false;
85 }
86 // ------------------------------------------------------------------------
88 virtual void finishedRace(float time) OVERRIDE
89 {
90 } // finishedRace
91 // ------------------------------------------------------------------------
93 core::stringw getName(bool include_handicap_string = true) const OVERRIDE;
94 // ------------------------------------------------------------------------
96 virtual void displayPenaltyWarning();
97
98}; // class PlayerController
99
100#endif // HEADER_PLAYER_CONTROLLER_HPP
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:53
This is the base class for kart controller - that can be a player or a a robot.
Definition: controller.hpp:46
Contains the state information of an item, i.e.
Definition: item.hpp:53
Definition: kart_rewinder.hpp:30
Definition: material.hpp:48
Definition: player_controller.hpp:28
core::stringw getName(bool include_handicap_string=true) const OVERRIDE
Returns the name of the player profile.
Definition: player_controller.cpp:400
virtual bool disableSlipstreamBonus() const OVERRIDE
Player will always be able to get a slipstream bonus.
Definition: player_controller.hpp:82
virtual bool isPlayerController() const OVERRIDE
This function checks if this player is not an AI, i.e.
Definition: player_controller.hpp:58
virtual void finishedRace(float time) OVERRIDE
Called when a race is finished.
Definition: player_controller.hpp:88
virtual ~PlayerController()
Destructor for a player kart.
Definition: player_controller.cpp:55
virtual void skidBonusTriggered() OVERRIDE
Callback when the skidding bonus is triggered.
Definition: player_controller.cpp:319
virtual void reset() OVERRIDE
Resets the player kart for a new or restarted race.
Definition: player_controller.cpp:62
virtual 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: player_controller.cpp:112
virtual void resetInputState()
Resets the state of control keys.
Definition: player_controller.cpp:78
virtual void newLap(int lap) OVERRIDE
Callback whenever a new lap is triggered.
Definition: player_controller.hpp:77
virtual void displayPenaltyWarning()
Called when this kart started too early and got a start penalty.
Definition: player_controller.cpp:421
virtual void setPosition(int p) OVERRIDE
Called just before the position of the kart is changed.
Definition: player_controller.hpp:63
virtual void update(int ticks) OVERRIDE
Updates the player kart, called once each timestep.
Definition: player_controller.cpp:327
virtual void handleZipper(bool play_sound) OVERRIDE
Called when a kart hits or uses a zipper.
Definition: player_controller.cpp:371
virtual void steer(int ticks, int steer_val)
Handles steering for a player kart.
Definition: player_controller.cpp:268
virtual bool isLocalPlayerController() const OVERRIDE
This function checks if this is a local player.
Definition: player_controller.hpp:60
PlayerAction
types of input events / what actions the players can do
Definition: input.hpp:117