mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Tilt camera on player damage (tweaked by PilzAdam)
This commit is contained in:
parent
5a13c49492
commit
a27cdf16f4
3 changed files with 31 additions and 2 deletions
23
src/game.cpp
23
src/game.cpp
|
@ -1356,6 +1356,10 @@ void the_game(
|
|||
// NOTE: So we have to use getTime() and call run()s between them
|
||||
u32 lasttime = device->getTimer()->getTime();
|
||||
|
||||
LocalPlayer* player = client.getEnv().getLocalPlayer();
|
||||
player->hurt_tilt_timer = 0;
|
||||
player->hurt_tilt_strength = 0;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
if(device->run() == false || kill == true)
|
||||
|
@ -2055,8 +2059,13 @@ void the_game(
|
|||
{
|
||||
//u16 damage = event.player_damage.amount;
|
||||
//infostream<<"Player damage: "<<damage<<std::endl;
|
||||
|
||||
damage_flash += 100.0;
|
||||
damage_flash += 8.0 * event.player_damage.amount;
|
||||
|
||||
player->hurt_tilt_timer = 1.5;
|
||||
player->hurt_tilt_strength = event.player_damage.amount/2;
|
||||
player->hurt_tilt_strength = rangelim(player->hurt_tilt_strength, 2.0, 10.0);
|
||||
}
|
||||
else if(event.type == CE_PLAYER_FORCE_MOVE)
|
||||
{
|
||||
|
@ -2088,6 +2097,10 @@ void the_game(
|
|||
|
||||
damage_flash = 0;
|
||||
|
||||
LocalPlayer* player = client.getEnv().getLocalPlayer();
|
||||
player->hurt_tilt_timer = 0;
|
||||
player->hurt_tilt_strength = 0;
|
||||
|
||||
/*LocalPlayer* player = client.getLocalPlayer();
|
||||
player->setPosition(player->getPosition() + v3f(0,-BS,0));
|
||||
camera.update(player, busytime, screensize);*/
|
||||
|
@ -3057,6 +3070,16 @@ void the_game(
|
|||
damage_flash -= 100.0*dtime;
|
||||
}
|
||||
|
||||
/*
|
||||
Damage camera tilt
|
||||
*/
|
||||
if(player->hurt_tilt_timer > 0.0)
|
||||
{
|
||||
player->hurt_tilt_timer -= dtime*5;
|
||||
if(player->hurt_tilt_timer < 0)
|
||||
player->hurt_tilt_strength = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Draw gui
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue