-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInAirState.cpp
More file actions
32 lines (27 loc) · 866 Bytes
/
InAirState.cpp
File metadata and controls
32 lines (27 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <InAirState.h>
#include <Hero.h>
#include "HeroAnimations.h"
namespace actors
{
namespace hero
{
void InAirState::update(Hero& hero)
{
if (hero.rigid_body.is_on_floor())
hero.fsm_.change_state(HeroFsm::hero_state::on_floor);
if (hero.rigid_body.is_on_ladder() && !hero.rigid_body.is_going_up())
hero.fsm_.change_state(HeroFsm::hero_state::on_ladder);
const auto throttle8_x = hero.get_throttle8_x();
hero.rigid_body.set_velocity8_x(throttle8_x); // no inertia, classic feel
// bit dirty. can only do this because these animations are only 1 frame.
hero.animation_player_.set_animation(hero.rigid_body.is_going_up() ? &animations::hero::jump : &animations::hero::fall);
}
void InAirState::on_enter(Hero& hero)
{
hero.rigid_body.is_gravity_enabled = true;
}
void InAirState::on_exit(Hero& hero)
{
}
}
}