3 // SuperTux - A Jump'n Run
4 // Copyright (C) 2003 Tobias Glaesser <tobi.web@gmx.de>
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 2
9 // of the License, or (at your option) any later version.
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.
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 #ifndef SUPERTUX_PLAYER_H
20 #define SUPERTUX_PLAYER_H
25 #include "video/surface.h"
26 #include "special/moving_object.h"
27 #include "special/sprite.h"
28 #include "math/physic.h"
31 using namespace SuperTux;
37 #define TUX_SAFE_TIME 1.250
38 #define TUX_INVINCIBLE_TIME 10.0
39 #define TUX_INVINCIBLE_TIME_WARNING 2.0
40 #define TUX_FLAPPING_TIME 1 /* How long Tux can flap his wings to gain additional jump height */
41 #define TIME_WARNING 20 /* When to alert player they're low on time! */
46 #define SCORE_DISTRO 20
68 extern PlayerKeymap keymap;
70 struct player_input_type
84 void player_input_init(player_input_type* pplayer_input);
89 extern Surface* tux_life;
91 extern Sprite* smalltux_gameover;
92 extern Sprite* smalltux_star;
93 extern Sprite* bigtux_star;
95 #define GROWING_TIME 1.0
96 #define GROWING_FRAMES 7
97 extern Surface* growingtux_left[GROWING_FRAMES];
98 extern Surface* growingtux_right[GROWING_FRAMES];
104 : head(0), body(0), arms(0), feet(0)
113 void set_action(std::string action, int loops = -1);
114 void one_time_animation();
115 void draw(DrawingContext& context, const Vector& pos, int layer,
116 Uint32 drawing_effect = NONE_EFFECT);
124 extern TuxBodyParts* small_tux;
125 extern TuxBodyParts* big_tux;
126 extern TuxBodyParts* fire_tux;
127 extern TuxBodyParts* ice_tux;
129 class Player : public MovingObject
132 enum HurtMode { KILL, SHRINK };
133 enum Power { NONE_POWER, FIRE_POWER, ICE_POWER };
134 enum FallMode { ON_GROUND, JUMPING, TRAMPOLINE_JUMP, FALLING };
136 player_input_type input;
140 bool holding_something;
155 bool falling_from_flap;
159 float flapping_velocity;
161 // Ricardo's flapping
164 // temporary to help player's choosing a flapping
165 enum { MAREK_FLAP, RICARDO_FLAP, RYAN_FLAP, NONE_FLAP };
168 Timer2 invincible_timer;
169 Timer2 skidding_timer;
172 Timer2 shooting_timer; // used to show the arm when Tux is shooting
174 Timer2 growing_timer;
176 Timer2 flapping_timer;
183 int key_event(SDLKey key, int state);
188 PlayerStatus& get_status();
190 virtual void action(float elapsed_time);
191 virtual void draw(DrawingContext& context);
192 virtual HitResponse collision(GameObject& other, const CollisionHit& hit);
194 void make_invincible();
195 bool is_invincible() const
197 return invincible_timer.started();
199 void kill(HurtMode mode);
200 void player_remove_powerups();
201 void check_bounds(Camera* camera);
204 void grow(bool animate = false);
205 void move(const Vector& vector);
207 void bounce(BadGuy& badguy);
215 void handle_horizontal_input();
216 void handle_vertical_input();
217 void remove_powerups();
220 #endif /*SUPERTUX_PLAYER_H*/
222 /* Local Variables: */