- moved some collision code into the world class, since it only acts on world data
[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 extern texture_type tux_life;
64 extern std::vector<texture_type> tux_right;
65 extern std::vector<texture_type> tux_left;
66 extern texture_type smalltux_jump_left;
67 extern texture_type smalltux_jump_right;
68 extern texture_type smalltux_stand_left;
69 extern texture_type smalltux_stand_right;
70 extern texture_type bigtux_right[3];
71 extern texture_type bigtux_left[3];
72 extern texture_type bigtux_right_jump;
73 extern texture_type bigtux_left_jump;
74 extern texture_type ducktux_right;
75 extern texture_type ducktux_left;
76 extern texture_type skidtux_right;
77 extern texture_type skidtux_left;
78 extern texture_type firetux_right[3];
79 extern texture_type firetux_left[3];
80 extern texture_type bigfiretux_right[3];
81 extern texture_type bigfiretux_left[3];
82 extern texture_type bigfiretux_right_jump;
83 extern texture_type bigfiretux_left_jump;
84 extern texture_type duckfiretux_right;
85 extern texture_type duckfiretux_left;
86 extern texture_type skidfiretux_right;
87 extern texture_type skidfiretux_left;
88 extern texture_type cape_right[2];
89 extern texture_type cape_left[2];
90 extern texture_type bigcape_right[2];
91 extern texture_type bigcape_left[2];
92
93 class Player
94 {
95  public:
96   player_input_type  input;
97   player_keymap_type keymap;
98   int score;
99   int distros;
100   bool got_coffee;
101   int size;
102   bool duck;
103   DyingType dying;
104   int dir;
105   bool jumping;
106   int frame_;
107   int frame_main;
108   int lives;
109   base_type base;
110   base_type old_base;
111   base_type previous_base;
112   timer_type invincible_timer;
113   timer_type skidding_timer;
114   timer_type safe_timer;
115   timer_type frame_timer;
116   Physic physic;
117
118  public:
119   void init();
120   int  key_event(SDLKey key, int state);
121   void level_begin();
122   void action();
123   void handle_input();
124   void grabdistros();
125   void draw();
126   void collision(void* p_c_object, int c_object);
127   void kill(int mode);
128   void is_dying();
129   bool is_dead();
130   void player_remove_powerups();
131   void keep_in_bounds();
132   bool on_ground();
133   bool under_solid();
134  private:
135   void handle_horizontal_input(int dir);
136   void handle_vertical_input();
137   void remove_powerups();
138 };
139
140 #endif /*SUPERTUX_PLAYER_H*/