merged bad_guy patch from Matze Braun. (recycling Ricardo's stalactite patch and...
[supertux.git] / src / badguy.h
1 //
2 // Interface: badguy
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_BADGUY_H
14 #define SUPERTUX_BADGUY_H
15
16 #include "SDL.h"
17 #include "bitmask.h"
18 #include "type.h"
19 #include "timer.h"
20 #include "texture.h"
21 #include "physic.h"
22 #include "collision.h"
23
24 /* Enemy modes: */
25 enum {
26     NORMAL=0,
27     FLAT,
28     KICK,
29     HELD,
30
31     BOMB_TICKING,
32     BOMB_EXPLODE,
33
34     STALACTITE_SHAKING,
35     STALACTITE_FALL
36 };
37
38 extern texture_type img_bsod_squished_left;
39 extern texture_type img_bsod_squished_right;
40 extern texture_type img_bsod_falling_left;
41 extern texture_type img_bsod_falling_right;
42 extern texture_type img_laptop_flat_left;
43 extern texture_type img_laptop_flat_right;
44 extern texture_type img_laptop_falling_left;
45 extern texture_type img_laptop_falling_right;
46 extern texture_type img_bsod_left[4];
47 extern texture_type img_bsod_right[4];
48 extern texture_type img_laptop_left[3];
49 extern texture_type img_laptop_right[3];
50 extern texture_type img_money_left[2];
51 extern texture_type img_money_right[2];
52 extern texture_type img_mrbomb_left[4];
53 extern texture_type img_mrbomb_right[4];
54 extern texture_type img_stalactite;
55 extern texture_type img_stalactite_broken;
56
57 /* Bad guy kinds: */
58 enum BadGuyKind {
59   BAD_BSOD,
60   BAD_LAPTOP,
61   BAD_MONEY,
62   BAD_MRBOMB,
63   BAD_BOMB,
64   BAD_STALACTITE
65 };
66
67 BadGuyKind  badguykind_from_string(const std::string& str);
68 std::string badguykind_to_string(BadGuyKind kind);
69
70 struct BadGuyData
71 {
72   BadGuyKind kind;
73   int x;
74   int y;
75
76   BadGuyData(BadGuyKind kind_, int x_, int y_) 
77     : kind(kind_), x(x_), y(y_) {}
78
79   BadGuyData()
80     : kind(BAD_BSOD), x(0), y(0) {}
81 };
82
83 class Player;
84
85 /* Badguy type: */
86 class BadGuy
87 {
88  public:
89   int mode;
90   DyingType dying;
91   BadGuyKind kind;
92   bool seen;
93   int dir;
94   base_type base;
95   base_type old_base;
96   timer_type timer;
97   physic_type physic;
98
99  public:
100   void init(float x, float y, BadGuyKind kind);
101
102   void action();
103   void draw();
104
105   void collision(void* p_c_object, int c_object,
106           CollisionType type = COLLISION_NORMAL);
107   
108  private:
109   void fall();
110   void remove_me();
111
112   void action_bsod();
113   void draw_bsod();
114
115   void action_laptop();
116   void draw_laptop();
117    
118   void action_money(); 
119   void draw_money();
120
121   void action_bomb();
122   void draw_bomb();
123
124   void action_mrbomb();
125   void draw_mrbomb();
126
127   void action_stalactite();
128   void draw_stalactite();
129
130   void make_player_jump(Player* player);
131   void check_horizontal_bump(bool checkcliff = false);
132   void bump();
133   void squich(Player* player);
134 };
135
136 #endif /*SUPERTUX_BADGUY_H*/
137
138