projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
better sound for splash effect
[supertux.git]
/
src
/
badguy
/
badguy.cpp
diff --git
a/src/badguy/badguy.cpp
b/src/badguy/badguy.cpp
index
609b352
..
888694e
100644
(file)
--- a/
src/badguy/badguy.cpp
+++ b/
src/badguy/badguy.cpp
@@
-42,6
+42,7
@@
BadGuy::BadGuy(const Vector& pos, const std::string& sprite_name_, int layer_) :
start_dir(AUTO),
frozen(false),
ignited(false),
start_dir(AUTO),
frozen(false),
ignited(false),
+ in_water(false),
dead_script(),
state(STATE_INIT),
is_active_flag(),
dead_script(),
state(STATE_INIT),
is_active_flag(),
@@
-54,6
+55,7
@@
BadGuy::BadGuy(const Vector& pos, const std::string& sprite_name_, int layer_) :
SoundManager::current()->preload("sounds/squish.wav");
SoundManager::current()->preload("sounds/fall.wav");
SoundManager::current()->preload("sounds/squish.wav");
SoundManager::current()->preload("sounds/fall.wav");
+ SoundManager::current()->preload("sounds/splash.wav");
dir = (start_dir == AUTO) ? LEFT : start_dir;
}
dir = (start_dir == AUTO) ? LEFT : start_dir;
}
@@
-68,6
+70,7
@@
BadGuy::BadGuy(const Vector& pos, Direction direction, const std::string& sprite
start_dir(direction),
frozen(false),
ignited(false),
start_dir(direction),
frozen(false),
ignited(false),
+ in_water(false),
dead_script(),
state(STATE_INIT),
is_active_flag(),
dead_script(),
state(STATE_INIT),
is_active_flag(),
@@
-80,6
+83,7
@@
BadGuy::BadGuy(const Vector& pos, Direction direction, const std::string& sprite
SoundManager::current()->preload("sounds/squish.wav");
SoundManager::current()->preload("sounds/fall.wav");
SoundManager::current()->preload("sounds/squish.wav");
SoundManager::current()->preload("sounds/fall.wav");
+ SoundManager::current()->preload("sounds/splash.wav");
dir = (start_dir == AUTO) ? LEFT : start_dir;
}
dir = (start_dir == AUTO) ? LEFT : start_dir;
}
@@
-94,6
+98,7
@@
BadGuy::BadGuy(const Reader& reader, const std::string& sprite_name_, int layer_
start_dir(AUTO),
frozen(false),
ignited(false),
start_dir(AUTO),
frozen(false),
ignited(false),
+ in_water(false),
dead_script(),
state(STATE_INIT),
is_active_flag(),
dead_script(),
state(STATE_INIT),
is_active_flag(),
@@
-113,6
+118,7
@@
BadGuy::BadGuy(const Reader& reader, const std::string& sprite_name_, int layer_
SoundManager::current()->preload("sounds/squish.wav");
SoundManager::current()->preload("sounds/fall.wav");
SoundManager::current()->preload("sounds/squish.wav");
SoundManager::current()->preload("sounds/fall.wav");
+ SoundManager::current()->preload("sounds/splash.wav");
dir = (start_dir == AUTO) ? LEFT : start_dir;
}
dir = (start_dir == AUTO) ? LEFT : start_dir;
}
@@
-233,6
+239,16
@@
BadGuy::collision_tile(uint32_t tile_attributes)
// Don't kill badguys that have already been killed
if (!is_active()) return;
// Don't kill badguys that have already been killed
if (!is_active()) return;
+ if(tile_attributes & Tile::WATER && !is_in_water())
+ {
+ in_water = true;
+ SoundManager::current()->play("sounds/splash.wav", get_pos());
+ }
+ if(!(tile_attributes & Tile::WATER) && is_in_water())
+ {
+ in_water = false;
+ }
+
if(tile_attributes & Tile::HURTS) {
if (tile_attributes & Tile::FIRE) {
if (is_flammable()) ignite();
if(tile_attributes & Tile::HURTS) {
if (tile_attributes & Tile::FIRE) {
if (is_flammable()) ignite();
@@
-611,6
+627,12
@@
BadGuy::is_frozen() const
return frozen;
}
return frozen;
}
+bool
+BadGuy::is_in_water() const
+{
+ return in_water;
+}
+
void
BadGuy::ignite()
{
void
BadGuy::ignite()
{