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 "audio/sound.h"
31 #include "special/moving_object.h"
32 #include "math/physic.h"
33 #include "app/defines.h"
39 #define TUX_SAFE_TIME 1250
40 #define TUX_INVINCIBLE_TIME 10000
41 #define TUX_INVINCIBLE_TIME_WARNING 2000
42 #define TIME_WARNING 20000 /* When to alert player they're low on time! */
46 #define DISTROS_LIFEUP 100
51 #define SCORE_DISTRO 25
73 extern PlayerKeymap keymap;
75 struct player_input_type
87 void player_input_init(player_input_type* pplayer_input);
92 extern Surface* tux_life;
94 extern Sprite* smalltux_gameover;
95 extern Sprite* smalltux_star;
96 extern Sprite* largetux_star;
98 #define GROWING_TIME 1000
99 #define GROWING_FRAMES 7
100 extern Surface* growingtux_left[GROWING_FRAMES];
101 extern Surface* growingtux_right[GROWING_FRAMES];
122 extern PlayerSprite smalltux;
123 extern PlayerSprite largetux;
124 extern PlayerSprite firetux;
125 extern PlayerSprite icetux;
127 class Player : public MovingObject
130 enum HurtMode { KILL, SHRINK };
131 enum Power { NONE_POWER, FIRE_POWER, ICE_POWER };
132 enum FallMode { ON_GROUND, JUMPING, TRAMPOLINE_JUMP, FALLING };
134 player_input_type input;
138 bool holding_something;
154 base_type previous_base;
155 Timer invincible_timer;
156 Timer skidding_timer;
160 Timer shooting_timer; // used to show the arm when Tux is shooting
172 int key_event(SDLKey key, int state);
177 virtual void action(float elapsed_time);
178 virtual void draw(DrawingContext& context);
179 virtual void collision(const MovingObject& other_object,
182 void collision(void* p_c_object, int c_object);
183 void kill(HurtMode mode);
184 void player_remove_powerups();
185 void check_bounds(Camera* camera);
188 bool tiles_on_air(int tiles);
189 void grow(bool animate);
190 void move(const Vector& vector);
192 /** let the player jump a bit or more if jump button is hold down
193 (used when you hit a badguy) */
194 void bounce(BadGuy* badguy);
202 void handle_horizontal_input();
203 void handle_vertical_input();
204 void remove_powerups();
207 #endif /*SUPERTUX_PLAYER_H*/
209 /* Local Variables: */