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
28 #include "screen/texture.h"
29 #include "collision.h"
31 #include "moving_object.h"
36 #define TUX_SAFE_TIME 1250
37 #define TUX_INVINCIBLE_TIME 10000
38 #define TUX_INVINCIBLE_TIME_WARNING 2000
39 #define TIME_WARNING 20000 /* When to alert player they're low on time! */
43 #define DISTROS_LIFEUP 100
48 #define SCORE_DISTRO 25
65 extern PlayerKeymap keymap;
67 struct player_input_type
79 void player_input_init(player_input_type* pplayer_input);
84 extern Surface* tux_life;
86 extern Sprite* smalltux_gameover;
87 extern Sprite* smalltux_star;
88 extern Sprite* largetux_star;
90 #define GROWING_TIME 1000
91 #define GROWING_FRAMES 7
92 extern Surface* growingtux_left[GROWING_FRAMES];
93 extern Surface* growingtux_right[GROWING_FRAMES];
114 extern PlayerSprite smalltux;
115 extern PlayerSprite largetux;
116 extern PlayerSprite firetux;
117 extern PlayerSprite icetux;
119 class Player : public MovingObject
122 enum HurtMode { KILL, SHRINK };
123 enum Power { NONE_POWER, FIRE_POWER, ICE_POWER };
124 enum FallMode { ON_GROUND, JUMPING, TRAMPOLINE_JUMP, FALLING };
126 player_input_type input;
130 bool holding_something;
146 base_type previous_base;
147 Timer invincible_timer;
148 Timer skidding_timer;
152 Timer shooting_timer; // used to show the arm when Tux is shooting
164 int key_event(SDLKey key, int state);
169 virtual void action(float elapsed_time);
170 virtual void draw(DrawingContext& context);
171 virtual void collision(const MovingObject& other_object,
174 void collision(void* p_c_object, int c_object);
175 void kill(HurtMode mode);
176 void player_remove_powerups();
177 void check_bounds(Camera* camera);
180 bool tiles_on_air(int tiles);
181 void grow(bool animate);
182 void move(const Vector& vector);
189 void handle_horizontal_input();
190 void handle_vertical_input();
191 void remove_powerups();
194 #endif /*SUPERTUX_PLAYER_H*/
196 /* Local Variables: */