Merged changes from branches/supertux-milestone2-grumbel/ to trunk/supertux/
[supertux.git] / src / scripting / player.hpp
1 //  SuperTux
2 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 //
4 //  This program is free software: you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation, either version 3 of the License, or
7 //  (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, see <http://www.gnu.org/licenses/>.
16
17 #ifndef HEADER_SUPERTUX_SCRIPTING_PLAYER_HPP
18 #define HEADER_SUPERTUX_SCRIPTING_PLAYER_HPP
19
20 #ifndef SCRIPTING_API
21 #include <string>
22 #endif
23
24 namespace Scripting {
25
26 class Player
27 {
28 public:
29 #ifndef SCRIPTING_API
30   virtual ~Player()
31   {}
32 #endif
33
34   /**
35    * Set tux bonus.
36    * This can be "grow", "fireflower" or "iceflower" at the moment
37    */
38   virtual bool add_bonus(const std::string& bonus) = 0;
39   /**
40    * Give tux more coins
41    */
42   virtual void add_coins(int count) = 0;
43   /**
44    * Make tux invincible for a short amount of time
45    */
46   virtual void make_invincible() = 0;
47   /**
48    * Deactivate user/scripting input for Tux
49    */
50   virtual void deactivate() = 0;
51   /**
52    * Give control back to user/scripting
53    */
54   virtual void activate() = 0;
55   /**
56    * Make Tux walk
57    */
58   virtual void walk(float speed) = 0;
59   /**
60    * Set player visible or invisible
61    */
62   virtual void set_visible(bool visible) = 0;
63   /**
64    * returns true if the player is currently visible (that is he was not set
65    * invisible by the set_visible method)
66    */
67   virtual bool get_visible() = 0;
68
69   /**
70    * Hurts a player, if completely=true then the player will be killed even
71    * if he had grow or fireflower bonus
72    */
73   virtual void kill(bool completely) = 0;
74
75   /**
76    * Switches ghost mode on/off.
77    * Lets Tux float around and through solid objects.
78    */
79   virtual void set_ghost_mode(bool enable) = 0;
80
81   /**
82    * Returns whether ghost mode is currently enabled
83    */
84   virtual bool get_ghost_mode() = 0;
85
86   /**
87    * play cheer animation.
88    * This might need some space and behave in an unpredictable way. Best to use this at level end.
89    */
90   virtual void do_cheer() = 0;
91
92   /**
93    * duck down if possible.
94    * this won't last long as long as input is enabled.
95    */
96   virtual void do_duck() = 0;
97
98   /**
99    * stand back up if possible.
100    */
101   virtual void do_standup() = 0;
102
103   /**
104    * do a backflip if possible.
105    */
106   virtual void do_backflip() = 0;
107
108   /**
109    * jump in the air if possible
110    * sensible values for yspeed are negative - unless we want to jump into the ground of course
111    */
112   virtual void do_jump(float yspeed) = 0;
113
114   /**
115    * Orders the current GameSession to start a sequence
116    */
117   virtual void trigger_sequence(std::string sequence_name) = 0;
118
119   /**
120    * Uses a scriptable controller for all user input (or restores controls)
121    */
122   virtual void use_scripting_controller(bool use_or_release) = 0;
123
124   /**
125    * Instructs the scriptable controller to press or release a button 
126    */
127   virtual void do_scripting_controller(std::string control, bool pressed) = 0;
128
129 };
130
131 }
132
133 #endif
134
135 /* EOF */