1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add event manager and use it to trigger sounds

This commit is contained in:
Perttu Ahola 2012-03-23 20:23:03 +02:00
parent e53794868e
commit 6c14025b2d
15 changed files with 388 additions and 14 deletions

View file

@ -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