summaryrefslogtreecommitdiff
path: root/src/player.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-23 20:23:03 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-03-24 04:24:26 +0200
commit6c14025b2d416105915440e114de927c26e925ac (patch)
tree64396513416935f2c0eaf50115a61856bbc0f7f2 /src/player.cpp
parente53794868eaa33199a1f1011b2d5f517b6f68057 (diff)
downloadminetest-6c14025b2d416105915440e114de927c26e925ac.tar.gz
minetest-6c14025b2d416105915440e114de927c26e925ac.tar.bz2
minetest-6c14025b2d416105915440e114de927c26e925ac.zip
Add event manager and use it to trigger sounds
Diffstat (limited to 'src/player.cpp')
-rw-r--r--src/player.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/player.cpp b/src/player.cpp
index 48d2c2907..0d4a1cb69 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "collision.h"
#include "environment.h"
#include "gamedef.h"
+#include "event.h"
Player::Player(IGameDef *gamedef):
touching_ground(false),
@@ -367,6 +368,7 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
Player is allowed to jump when this is true.
*/
+ bool touching_ground_was = touching_ground;
touching_ground = false;
/*std::cout<<"Checking collisions for ("
@@ -608,6 +610,11 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
collision_info->push_back(info);
}
}
+
+ if(!touching_ground_was && touching_ground){
+ MtEvent *e = new SimpleTriggerEvent("PlayerRegainGround");
+ m_gamedef->event()->put(e);
+ }
}
void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d)
@@ -723,6 +730,9 @@ void LocalPlayer::applyControl(float dtime)
{
speed.Y = 6.5*BS;
setSpeed(speed);
+
+ MtEvent *e = new SimpleTriggerEvent("PlayerJump");
+ m_gamedef->event()->put(e);
}
}
// Use the oscillating value for getting out of water