projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
badguys now have normal hitpoints and bullet hitpoints, so you can make them need...
[supertux.git]
/
src
/
badguy
/
badguy.h
diff --git
a/src/badguy/badguy.h
b/src/badguy/badguy.h
index
d92d6b2
..
e770feb
100644
(file)
--- a/
src/badguy/badguy.h
+++ b/
src/badguy/badguy.h
@@
-7,12
+7,15
@@
#include "special/moving_object.h"
#include "special/sprite.h"
#include "math/physic.h"
#include "special/moving_object.h"
#include "special/sprite.h"
#include "math/physic.h"
-#include "player.h"
+#include "
object/
player.h"
#include "serializable.h"
#include "resources.h"
#include "sector.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"
#include "video/drawing_context.h"
#include "special/sprite_manager.h"
@@
-24,15
+27,35
@@
public:
BadGuy();
~BadGuy();
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);
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);
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);
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();
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,
protected:
enum State {
STATE_INIT,
@@
-41,17
+64,25
@@
protected:
STATE_SQUISHED,
STATE_FALLING
};
STATE_SQUISHED,
STATE_FALLING
};
-
+
+ /** Called when the badguy collided with a player */
virtual HitResponse collision_player(Player& player,
const CollisionHit& hit);
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);
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);
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);
virtual bool collision_squished(Player& player);
+ /** called each frame when the badguy is activated. */
virtual void active_action(float elapsed_time);
virtual void active_action(float elapsed_time);
+ /** called each frame when the badguy is not activated. */
virtual void inactive_action(float elapsed_time);
/**
virtual void inactive_action(float elapsed_time);
/**
@@
-59,7
+90,7
@@
protected:
* variable might have been changed so that it faces towards the player.
*/
virtual void activate();
* variable might have been changed so that it faces towards the player.
*/
virtual void activate();
- /** cal
e
ed when the badguy has been deactivated */
+ /** cal
l
ed when the badguy has been deactivated */
virtual void deactivate();
void kill_squished(Player& player);
virtual void deactivate();
void kill_squished(Player& player);
@@
-84,11
+115,15
@@
protected:
* initial position of the enemy. Also the position where enemy respawns when
* after being deactivated.
*/
* initial position of the enemy. Also the position where enemy respawns when
* after being deactivated.
*/
+ bool is_offscreen();
+
Vector start_position;
Direction dir;
Vector start_position;
Direction dir;
+
+ int hitpoints;
+ int bullet_hitpoints;
private:
private:
- bool is_offscreen();
void try_activate();
State state;
void try_activate();
State state;