projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Set 'licence' attribute on sound files
[supertux.git]
/
src
/
badguy
/
willowisp.cpp
diff --git
a/src/badguy/willowisp.cpp
b/src/badguy/willowisp.cpp
index
b0fe7c6
..
db467e7
100644
(file)
--- a/
src/badguy/willowisp.cpp
+++ b/
src/badguy/willowisp.cpp
@@
-20,11
+20,20
@@
#include <config.h>
#include "willowisp.hpp"
#include <config.h>
#include "willowisp.hpp"
+
#include "log.hpp"
#include "game_session.hpp"
#include "object/lantern.hpp"
#include "object/player.hpp"
#include "scripting/squirrel_util.hpp"
#include "log.hpp"
#include "game_session.hpp"
#include "object/lantern.hpp"
#include "object/player.hpp"
#include "scripting/squirrel_util.hpp"
+#include "object/path.hpp"
+#include "object/path_walker.hpp"
+#include "audio/sound_source.hpp"
+#include "lisp/writer.hpp"
+#include "object_factory.hpp"
+#include "audio/sound_manager.hpp"
+#include "sector.hpp"
+#include "sprite/sprite.hpp"
static const float FLYSPEED = 64; /**< speed in px per second */
static const float TRACK_RANGE = 384; /**< at what distance to start tracking the player */
static const float FLYSPEED = 64; /**< speed in px per second */
static const float TRACK_RANGE = 384; /**< at what distance to start tracking the player */
@@
-97,11
+106,14
@@
WillOWisp::active_update(float elapsed_time)
break;
case STATE_TRACKING:
break;
case STATE_TRACKING:
- if (dist.norm() <= vanish_range) {
+ if (dist.norm() > vanish_range) {
+ vanish();
+ } else if (dist.norm() >= 1) {
Vector dir = dist.unit();
movement = dir * elapsed_time * flyspeed;
} else {
Vector dir = dist.unit();
movement = dir * elapsed_time * flyspeed;
} else {
- vanish();
+ /* We somehow landed right on top of the player without colliding.
+ * Sit tight and avoid a division by zero. */
}
sound_source->set_position(get_pos());
break;
}
sound_source->set_position(get_pos());
break;
@@
-251,7
+263,7
@@
WillOWisp::set_state(const std::string& new_state)
} else {
std::ostringstream msg;
msg << "Can't set unknown willowisp state '" << new_state << "', should "
} else {
std::ostringstream msg;
msg << "Can't set unknown willowisp state '" << new_state << "', should "
- "be stopped, move_path, move_path_track or normal";
+
"be stopped, move_path, move_path_track or normal";
throw new std::runtime_error(msg.str());
}
}
throw new std::runtime_error(msg.str());
}
}