- fixed some align problems with tux
[supertux.git] / src / player.h
1 //
2 // Interface: player/tux
3 //
4 // Description: 
5 //
6 //
7 // Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2003
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12
13 #ifndef SUPERTUX_PLAYER_H
14 #define SUPERTUX_PLAYER_H
15
16 #include <SDL.h>
17 #include "bitmask.h"
18 #include "type.h"
19 #include "timer.h"
20 #include "texture.h"
21 #include "collision.h"
22 #include "sound.h"
23 #include "physic.h"
24
25 /* Times: */
26
27 #define TUX_SAFE_TIME 750
28 #define TUX_INVINCIBLE_TIME 10000
29 #define TIME_WARNING 20000     /* When to alert player they're low on time! */
30
31 /* One-ups... */
32
33 #define DISTROS_LIFEUP 100
34
35 /* Scores: */
36
37 #define SCORE_BRICK 5
38 #define SCORE_DISTRO 25
39
40 #include <vector>
41
42 struct player_keymap_type
43 {
44   int jump;
45   int duck;
46   int left;
47   int right;
48   int fire;
49 };
50
51 struct player_input_type
52 {
53   int right;
54   int left;
55   int up;
56   int down;
57   int fire;
58   int old_fire;
59 };
60
61 void player_input_init(player_input_type* pplayer_input);
62
63 class Sprite;
64
65 extern Surface* tux_life;
66 extern std::vector<Surface*> tux_right;
67 extern std::vector<Surface*> tux_left;
68 extern Surface* smalltux_jump_left;
69 extern Surface* smalltux_jump_right;
70 extern Surface* smalltux_stand_left;
71 extern Surface* smalltux_stand_right;
72 extern Sprite* bigtux_right;
73 extern Sprite* bigtux_left;
74 extern Sprite* bigtux_right_jump;
75 extern Sprite* bigtux_left_jump;
76 extern Sprite* ducktux_right;
77 extern Sprite* ducktux_left;
78 extern Surface* skidtux_right;
79 extern Surface* skidtux_left;
80 extern Surface* firetux_right[3];
81 extern Surface* firetux_left[3];
82 extern Surface* bigfiretux_right[3];
83 extern Surface* bigfiretux_left[3];
84 extern Surface* bigfiretux_right_jump;
85 extern Surface* bigfiretux_left_jump;
86 extern Surface* duckfiretux_right;
87 extern Surface* duckfiretux_left;
88 extern Surface* skidfiretux_right;
89 extern Surface* skidfiretux_left;
90 extern Surface* cape_right[2];
91 extern Surface* cape_left[2];
92 extern Surface* bigcape_right[2];
93 extern Surface* bigcape_left[2];
94
95 class Player
96 {
97  public:
98   player_keymap_type keymap;
99
100   player_input_type  input;
101   bool got_coffee;
102   int size;
103   bool duck;
104   DyingType dying;
105   int dir;
106   bool jumping;
107   int frame_;
108   int frame_main;
109
110   base_type  base;
111   base_type  old_base;
112   base_type  previous_base;
113   Timer invincible_timer;
114   Timer skidding_timer;
115   Timer safe_timer;
116   Timer frame_timer;
117   Physic physic;
118
119  public:
120   void init();
121   int  key_event(SDLKey key, int state);
122   void level_begin();
123   void action(double frame_ratio);
124   void handle_input();
125   void grabdistros();
126   void draw();
127   void collision(void* p_c_object, int c_object);
128   void kill(int mode);
129   void is_dying();
130   bool is_dead();
131   void player_remove_powerups();
132   void keep_in_bounds();
133   bool on_ground();
134   bool under_solid();
135   
136  private:
137   void handle_horizontal_input();
138   void handle_vertical_input();
139   void remove_powerups();
140 };
141
142 #endif /*SUPERTUX_PLAYER_H*/