4 // moved them here to make it less typing when implementing new badguys
7 #include "special/moving_object.h"
8 #include "special/sprite.h"
9 #include "math/physic.h"
10 #include "object/player.h"
11 #include "serializable.h"
12 #include "resources.h"
14 #include "direction.h"
15 #include "object_factory.h"
16 #include "lisp/parser.h"
17 #include "lisp/lisp.h"
18 #include "lisp/writer.h"
19 #include "video/drawing_context.h"
20 #include "special/sprite_manager.h"
22 using namespace SuperTux;
24 class BadGuy : public MovingObject, public Serializable
30 /** Called when the badguy is drawn. The default implementation simply draws
31 * the badguy sprite on screen
33 virtual void draw(DrawingContext& context);
34 /** Called each frame. The default implementation checks badguy state and
35 * calls active_action and inactive_action
37 virtual void action(float elapsed_time);
38 /** Called when a collision with another object occured. The default
39 * implemetnation calls collision_player, collision_solid, collision_badguy
40 * and collision_squished
42 virtual HitResponse collision(GameObject& other,
43 const CollisionHit& hit);
45 /** Set the badguy to kill/falling state, which makes him falling of the
46 * screen (his sprite is turned upside-down)
48 virtual void kill_fall();
50 Vector get_start_position() const
52 return start_position;
54 void set_start_position(const Vector& vec)
68 /** Called when the badguy collided with a player */
69 virtual HitResponse collision_player(Player& player,
70 const CollisionHit& hit);
71 /** Called when the badguy collided with solid ground */
72 virtual HitResponse collision_solid(GameObject& other,
73 const CollisionHit& hit);
74 /** Called when the badguy collided with another badguy */
75 virtual HitResponse collision_badguy(BadGuy& other,
76 const CollisionHit& hit);
78 /** Called when the player hit the badguy from above. You should return true
79 * if the badguy was squished, false if squishing wasn't possible
81 virtual bool collision_squished(Player& player);
83 /** called each frame when the badguy is activated. */
84 virtual void active_action(float elapsed_time);
85 /** called each frame when the badguy is not activated. */
86 virtual void inactive_action(float elapsed_time);
89 * called when the badguy has been activated. (As a side effect the dir
90 * variable might have been changed so that it faces towards the player.
92 virtual void activate();
93 /** caleed when the badguy has been deactivated */
94 virtual void deactivate();
96 void kill_squished(Player& player);
98 void set_state(State state);
99 State get_state() const
103 * returns a pointer to the player, try to avoid this function to avoid
104 * problems later when we have multiple players or no player in scripted
107 Player* get_player();
112 /// is the enemy activated
115 * initial position of the enemy. Also the position where enemy respawns when
116 * after being deactivated.
120 Vector start_position;