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
28 #include "utils/lispreader.h"
29 #include "special/timer.h"
30 #include "math/physic.h"
32 #include "special/moving_object.h"
33 #include "collision.h"
34 #include "serializable.h"
37 using namespace SuperTux;
39 /* Timing constants (in ms): */
41 #define KICKING_TIME 200
64 BadGuyKind badguykind_from_string(const std::string& str);
65 std::string badguykind_to_string(BadGuyKind kind);
71 class BadGuy : public MovingObject, public Serializable
102 /** If true the enemy will stay on its current platform, ie. if he
103 reaches the edge he will turn around and walk into the other
104 direction, if false the enemy will jump or walk of the edge */
105 bool stay_on_platform;
108 Vector start_position;
110 Timer frozen_timer; // gets frozen when a ice shot hits it
115 int squishcount; /// number of times this enemy was squiched
116 Vector target; // Target that badguy is aiming for (wingling uses this)
121 std::string action_left, action_right;
125 int animation_offset;
128 BadGuy(BadGuyKind kind, float x, float y);
129 BadGuy(BadGuyKind kind, LispReader& reader);
132 virtual void write(LispWriter& writer);
134 virtual void action(float frame_ratio);
135 virtual void draw(DrawingContext& context);
136 virtual void collision(const MovingObject& other, int type);
138 void collision(void* p_c_object, int c_object,
139 CollisionType type = COLLISION_NORMAL);
141 /** this functions tries to kill the badguy and lets him fall off the
142 * screen. Some badguys like the flame might ignore this.
144 void kill_me(int score);
146 /** initializes the badguy (when he appears on screen) */
147 void activate(Direction direction); // should only be used by BadGuy's objects
149 Surface* get_image();
154 void action_mriceblock(double frame_ratio);
155 void action_jumpy(double frame_ratio);
156 void action_bomb(double frame_ratio);
157 void action_mrbomb(double frame_ratio);
158 void action_stalactite(double frame_ratio);
159 void action_flame(double frame_ratio);
160 void action_fish(double frame_ratio);
161 void action_bouncingsnowball(double frame_ratio);
162 void action_flyingsnowball(double frame_ratio);
163 void action_spiky(double frame_ratio);
164 void action_snowball(double frame_ratio);
165 void action_wingling(double frame_ratio);
166 void action_walkingtree(double frame_ratio);
168 /** handles falling down. disables gravity calculation when we're back on
172 /** Turn enemy into a bomb. To explode right way pass true */
173 void explode(bool right_away);
175 /** check if we're running left or right in a wall and eventually change
178 void check_horizontal_bump(bool checkcliff = false);
179 /** called when we're bumped from below with a block */
181 /** called when a player jumped on the badguy from above */
182 void squish(Player* player);
183 /** squish ourself, give player score and set dying to DYING_SQICHED */
184 void squish_me(Player* player);
185 /** set sprite's action of the badguy */
186 void set_action(std::string action_left, std::string action_right);
189 #endif /*SUPERTUX_BADGUY_H*/
191 /* Local Variables: */