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.
20 #ifndef SUPERTUX_PLAYER_H
21 #define SUPERTUX_PLAYER_H
26 #include "special/timer.h"
27 #include "special/base.h"
28 #include "video/surface.h"
29 #include "collision.h"
30 #include "special/moving_object.h"
31 #include "math/physic.h"
34 using namespace SuperTux;
40 #define TUX_SAFE_TIME 1250
41 #define TUX_INVINCIBLE_TIME 10000
42 #define TUX_INVINCIBLE_TIME_WARNING 2000
43 #define TIME_WARNING 20000 /* When to alert player they're low on time! */
47 #define DISTROS_LIFEUP 100
52 #define SCORE_DISTRO 20
74 extern PlayerKeymap keymap;
76 struct player_input_type
88 void player_input_init(player_input_type* pplayer_input);
95 extern Surface* tux_life;
97 extern Sprite* smalltux_gameover;
98 extern Sprite* smalltux_star;
99 extern Sprite* bigtux_star;
101 #define GROWING_TIME 1000
102 #define GROWING_FRAMES 7
103 extern Surface* growingtux_left[GROWING_FRAMES];
104 extern Surface* growingtux_right[GROWING_FRAMES];
112 void set_action(std::string action);
113 void one_time_animation();
114 void draw(DrawingContext& context, const Vector& pos, int layer,
115 Uint32 drawing_effect = NONE_EFFECT);
123 extern TuxBodyParts* small_tux;
124 extern TuxBodyParts* big_tux;
125 extern TuxBodyParts* fire_tux;
126 extern TuxBodyParts* ice_tux;
128 class Player : public MovingObject
131 enum HurtMode { KILL, SHRINK };
132 enum Power { NONE_POWER, FIRE_POWER, ICE_POWER };
133 enum FallMode { ON_GROUND, JUMPING, TRAMPOLINE_JUMP, FALLING };
135 player_input_type input;
139 bool holding_something;
155 base_type previous_base;
156 Timer invincible_timer;
157 Timer skidding_timer;
161 Timer shooting_timer; // used to show the arm when Tux is shooting
171 int key_event(SDLKey key, int state);
176 virtual void action(float elapsed_time);
177 virtual void draw(DrawingContext& context);
178 virtual void collision(const MovingObject& other_object,
181 void collision(void* p_c_object, int c_object);
182 void kill(HurtMode mode);
183 void player_remove_powerups();
184 void check_bounds(Camera* camera);
187 bool tiles_on_air(int tiles);
188 void grow(bool animate);
189 void move(const Vector& vector);
191 /** let the player jump a bit or more if jump button is hold down
192 (used when you hit a badguy) */
193 void bounce(BadGuy* badguy);
201 void handle_horizontal_input();
202 void handle_vertical_input();
203 void remove_powerups();
206 #endif /*SUPERTUX_PLAYER_H*/
208 /* Local Variables: */