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
26 #include "direction.h"
27 #include "video/surface.h"
28 #include "special/moving_object.h"
29 #include "special/sprite.h"
30 #include "math/physic.h"
32 using namespace SuperTux;
39 #define TUX_SAFE_TIME 1.250
40 #define TUX_INVINCIBLE_TIME 10.0
41 #define TUX_INVINCIBLE_TIME_WARNING 2.0
42 #define TUX_FLAPPING_TIME 1 /* How long Tux can flap his wings to gain additional jump height */
43 #define TIME_WARNING 20 /* When to alert player they're low on time! */
62 extern PlayerKeymap keymap;
64 /** Contains a field of booleans that indicate wheter a button is pressed or
65 * released. The old_ fields contain the state of the button at the previous
68 struct PlayerInputType
89 extern Surface* tux_life;
91 #define GROWING_TIME 1.0
92 #define GROWING_FRAMES 7
93 extern Surface* growingtux_left[GROWING_FRAMES];
94 extern Surface* growingtux_right[GROWING_FRAMES];
100 : head(0), body(0), arms(0), feet(0)
109 void set_action(std::string action, int loops = -1);
110 void one_time_animation();
111 void draw(DrawingContext& context, const Vector& pos, int layer,
112 Uint32 drawing_effect = NONE_EFFECT);
120 extern TuxBodyParts* small_tux;
121 extern TuxBodyParts* big_tux;
122 extern TuxBodyParts* fire_tux;
123 extern TuxBodyParts* ice_tux;
125 class Player : public MovingObject
128 enum HurtMode { KILL, SHRINK };
129 enum Power { NONE_POWER, FIRE_POWER, ICE_POWER };
130 enum FallMode { ON_GROUND, JUMPING, TRAMPOLINE_JUMP, FALLING };
132 PlayerInputType input;
153 bool falling_from_flap;
157 float flapping_velocity;
159 // Ricardo's flapping
162 // temporary to help player's choosing a flapping
163 enum { MAREK_FLAP, RICARDO_FLAP, RYAN_FLAP, NONE_FLAP };
166 Timer2 invincible_timer;
167 Timer2 skidding_timer;
170 Timer2 shooting_timer; // used to show the arm when Tux is shooting
172 Timer2 growing_timer;
174 Timer2 flapping_timer;
181 bool key_event(SDLKey key, bool state);
185 PlayerStatus& get_status();
187 virtual void action(float elapsed_time);
188 virtual void draw(DrawingContext& context);
189 virtual HitResponse collision(GameObject& other, const CollisionHit& hit);
191 void make_invincible();
192 bool is_invincible() const
194 return invincible_timer.started();
196 bool is_dying() const
201 void kill(HurtMode mode);
202 void player_remove_powerups();
203 void check_bounds(Camera* camera);
204 void grow(bool animate = false);
205 void move(const Vector& vector);
207 void bounce(BadGuy& badguy);
217 void handle_horizontal_input();
218 void handle_vertical_input();
219 void remove_powerups();
221 Portable* grabbed_object;
223 Sprite* smalltux_gameover;
224 Sprite* smalltux_star;
228 #endif /*SUPERTUX_PLAYER_H*/