projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
*possible* fix for bugs #453 and #373
[supertux.git]
/
src
/
badguy
/
walking_badguy.cpp
diff --git
a/src/badguy/walking_badguy.cpp
b/src/badguy/walking_badguy.cpp
index
a3c0562
..
627e62c
100644
(file)
--- a/
src/badguy/walking_badguy.cpp
+++ b/
src/badguy/walking_badguy.cpp
@@
-21,32
+21,32
@@
#include "walking_badguy.hpp"
#include "log.hpp"
#include "walking_badguy.hpp"
#include "log.hpp"
-
+#include "timer.hpp"
WalkingBadguy::WalkingBadguy(const Vector& pos, const std::string& sprite_name, const std::string& walk_left_action, const std::string& walk_right_action, int layer)
WalkingBadguy::WalkingBadguy(const Vector& pos, const std::string& sprite_name, const std::string& walk_left_action, const std::string& walk_right_action, int layer)
-
: BadGuy(pos, sprite_name, layer), walk_left_action(walk_left_action), walk_right_action(walk_right_action), walk_speed(80), max_drop_height(-1)
+ : BadGuy(pos, sprite_name, layer), walk_left_action(walk_left_action), walk_right_action(walk_right_action), walk_speed(80), max_drop_height(-1)
{
}
WalkingBadguy::WalkingBadguy(const Vector& pos, Direction direction, const std::string& sprite_name, const std::string& walk_left_action, const std::string& walk_right_action, int layer)
{
}
WalkingBadguy::WalkingBadguy(const Vector& pos, Direction direction, const std::string& sprite_name, const std::string& walk_left_action, const std::string& walk_right_action, int layer)
-
: BadGuy(pos, direction, sprite_name, layer), walk_left_action(walk_left_action), walk_right_action(walk_right_action), walk_speed(80), max_drop_height(-1)
+ : BadGuy(pos, direction, sprite_name, layer), walk_left_action(walk_left_action), walk_right_action(walk_right_action), walk_speed(80), max_drop_height(-1)
{
}
WalkingBadguy::WalkingBadguy(const lisp::Lisp& reader, const std::string& sprite_name, const std::string& walk_left_action, const std::string& walk_right_action, int layer)
{
}
WalkingBadguy::WalkingBadguy(const lisp::Lisp& reader, const std::string& sprite_name, const std::string& walk_left_action, const std::string& walk_right_action, int layer)
-
: BadGuy(reader, sprite_name, layer), walk_left_action(walk_left_action), walk_right_action(walk_right_action), walk_speed(80), max_drop_height(-1)
+ : BadGuy(reader, sprite_name, layer), walk_left_action(walk_left_action), walk_right_action(walk_right_action), walk_speed(80), max_drop_height(-1)
{
}
void
WalkingBadguy::write(lisp::Writer& writer)
{
{
}
void
WalkingBadguy::write(lisp::Writer& writer)
{
- writer.write
_float
("x", start_position.x);
- writer.write
_float
("y", start_position.y);
+ writer.write("x", start_position.x);
+ writer.write("y", start_position.y);
}
void
}
void
-WalkingBadguy::
activat
e()
+WalkingBadguy::
initializ
e()
{
if(frozen)
return;
{
if(frozen)
return;
@@
-107,6
+107,15
@@
WalkingBadguy::turn_around()
dir = dir == LEFT ? RIGHT : LEFT;
sprite->set_action(dir == LEFT ? walk_left_action : walk_right_action);
physic.set_velocity_x(-physic.get_velocity_x());
dir = dir == LEFT ? RIGHT : LEFT;
sprite->set_action(dir == LEFT ? walk_left_action : walk_right_action);
physic.set_velocity_x(-physic.get_velocity_x());
+
+ // if we get dizzy, we fall off the screen
+ if (turn_around_timer.started()) {
+ if (turn_around_counter++ > 10) kill_fall();
+ } else {
+ turn_around_timer.start(1);
+ turn_around_counter = 0;
+ }
+
}
void
}
void
@@
-120,7
+129,7
@@
void
WalkingBadguy::unfreeze()
{
BadGuy::unfreeze();
WalkingBadguy::unfreeze()
{
BadGuy::unfreeze();
- WalkingBadguy::
activat
e();
+ WalkingBadguy::
initializ
e();
}
}