X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fbadguy%2Fbadguy.h;h=ef17b751c28c1a230e613cfe5266dea64dd88368;hb=864c93e01ec366f730b3ebad08d5c52d6a9363b6;hp=d92d6b2ff86fc317a8d1f4c8dbe850fd24d7f367;hpb=d46c78c842ab4090a3f46e560c891234167f124b;p=supertux.git diff --git a/src/badguy/badguy.h b/src/badguy/badguy.h index d92d6b2ff..ef17b751c 100644 --- a/src/badguy/badguy.h +++ b/src/badguy/badguy.h @@ -1,22 +1,42 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. #ifndef __BADGUY_H__ #define __BADGUY_H__ // moved them here to make it less typing when implementing new badguys #include #include "timer.h" -#include "special/moving_object.h" -#include "special/sprite.h" -#include "math/physic.h" -#include "player.h" +#include "moving_object.h" +#include "sprite/sprite.h" +#include "physic.h" +#include "object/player.h" #include "serializable.h" #include "resources.h" #include "sector.h" -#include "utils/lispwriter.h" -#include "utils/lispreader.h" +#include "direction.h" +#include "object_factory.h" +#include "lisp/parser.h" +#include "lisp/lisp.h" +#include "lisp/writer.h" #include "video/drawing_context.h" -#include "special/sprite_manager.h" - -using namespace SuperTux; +#include "sprite/sprite_manager.h" class BadGuy : public MovingObject, public Serializable { @@ -24,15 +44,35 @@ public: BadGuy(); ~BadGuy(); - //virtual void action_activated(float elapsed_time); - + /** Called when the badguy is drawn. The default implementation simply draws + * the badguy sprite on screen + */ virtual void draw(DrawingContext& context); + /** Called each frame. The default implementation checks badguy state and + * calls active_action and inactive_action + */ virtual void action(float elapsed_time); + /** Called when a collision with another object occured. The default + * implemetnation calls collision_player, collision_solid, collision_badguy + * and collision_squished + */ virtual HitResponse collision(GameObject& other, const CollisionHit& hit); + /** Set the badguy to kill/falling state, which makes him falling of the + * screen (his sprite is turned upside-down) + */ virtual void kill_fall(); + Vector get_start_position() const + { + return start_position; + } + void set_start_position(const Vector& vec) + { + start_position = vec; + } + protected: enum State { STATE_INIT, @@ -41,17 +81,25 @@ protected: STATE_SQUISHED, STATE_FALLING }; - + + /** Called when the badguy collided with a player */ virtual HitResponse collision_player(Player& player, const CollisionHit& hit); + /** Called when the badguy collided with solid ground */ virtual HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + /** Called when the badguy collided with another badguy */ virtual HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit); - + + /** Called when the player hit the badguy from above. You should return true + * if the badguy was squished, false if squishing wasn't possible + */ virtual bool collision_squished(Player& player); + /** called each frame when the badguy is activated. */ virtual void active_action(float elapsed_time); + /** called each frame when the badguy is not activated. */ virtual void inactive_action(float elapsed_time); /** @@ -59,7 +107,7 @@ protected: * variable might have been changed so that it faces towards the player. */ virtual void activate(); - /** caleed when the badguy has been deactivated */ + /** called when the badguy has been deactivated */ virtual void deactivate(); void kill_squished(Player& player); @@ -84,15 +132,19 @@ protected: * initial position of the enemy. Also the position where enemy respawns when * after being deactivated. */ + bool is_offscreen(); + Vector start_position; Direction dir; + + int hitpoints; + int bullet_hitpoints; private: - bool is_offscreen(); void try_activate(); State state; - Timer2 state_timer; + Timer state_timer; }; #endif