4 // Copyright (C) 2000 Bill Kendrick <bill@newbreedsoftware.com>
5 // Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
6 // Copyright (C) 2004 Matthias Braun <matze@braunis.de>
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version 2
11 // of the License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 #ifndef SUPERTUX_BADGUY_H
24 #define SUPERTUX_BADGUY_H
33 #include "collision.h"
52 BadGuyKind badguykind_from_string(const std::string& str);
53 std::string badguykind_to_string(BadGuyKind kind);
54 void load_badguy_gfx();
55 void free_badguy_gfx();
60 class BadGuy : public GameObject
88 /** If true the enemy will stay on its current platform, ie. if he
89 reaches the edge he will turn around and walk into the other
90 direction, if false the enemy will jump or walk of the edge */
91 bool stay_on_platform;
95 Timer frozen_timer; // gets frozen when a ice shot hits it
100 int squishcount; /// number of times this enemy was squiched
105 Sprite* sprite_right;
107 int animation_offset;
110 BadGuy(float x, float y, BadGuyKind kind, bool stay_on_platform);
112 void action(double frame_ratio);
114 std::string type() { return "BadGuy"; };
116 void explode(BadGuy* badguy);
118 void collision(void* p_c_object, int c_object,
119 CollisionType type = COLLISION_NORMAL);
121 /** this functions tries to kill the badguy and lets him fall off the
122 * screen. Some badguys like the flame might ignore this.
124 void kill_me(int score);
126 /** remove ourself from the list of badguys. WARNING! This function will
127 * invalidate all members. So don't do anything else with member after calling
131 bool is_removable() const { return removable; }
134 void action_mriceblock(double frame_ratio);
135 void action_jumpy(double frame_ratio);
136 void action_bomb(double frame_ratio);
137 void action_mrbomb(double frame_ratio);
138 void action_stalactite(double frame_ratio);
139 void action_flame(double frame_ratio);
140 void action_fish(double frame_ratio);
141 void action_bouncingsnowball(double frame_ratio);
142 void action_flyingsnowball(double frame_ratio);
143 void action_spiky(double frame_ratio);
144 void action_snowball(double frame_ratio);
146 /** handles falling down. disables gravity calculation when we're back on
150 /** let the player jump a bit (used when you hit a badguy) */
151 void make_player_jump(Player* player);
153 /** check if we're running left or right in a wall and eventually change
156 void check_horizontal_bump(bool checkcliff = false);
157 /** called when we're bumped from below with a block */
159 /** called when a player jumped on the badguy from above */
160 void squish(Player* player);
161 /** squish ourself, give player score and set dying to DYING_SQICHED */
162 void squish_me(Player* player);
163 /** set image of the badguy */
164 void set_sprite(Sprite* left, Sprite* right);
172 bool stay_on_platform;
174 BadGuyData(BadGuy* pbadguy) : kind(pbadguy->kind), x((int)pbadguy->base.x), y((int)pbadguy->base.y), stay_on_platform(pbadguy->stay_on_platform) {};
175 BadGuyData(BadGuyKind kind_, int x_, int y_, bool stay_on_platform_)
176 : kind(kind_), x(x_), y(y_), stay_on_platform(stay_on_platform_) {}
179 : kind(BAD_SNOWBALL), x(0), y(0), stay_on_platform(false) {}
188 std::vector<BadGuy*> badguys;
189 static BadGuyManager* instance_ ;
191 void load_badguys(std::string filename);
194 static BadGuyManager* instance() { return instance_ ? instance_ : instance_ = new BadGuyManager(); }
195 static void destroy_instance() { delete instance_; instance_ = 0; }
197 BadGuy* get(unsigned int id) {
198 if(id < badguys.size())
204 // Never return 0, but return the 0th tile instead so that
205 // user code doesn't have to check for NULL pointers all over
212 #endif /*SUPERTUX_BADGUY_H*/
214 /* Local Variables: */