A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectDossunNormal.cc
1#include "ObjectDossunNormal.hh"
2
3namespace Field {
4
6ObjectDossunNormal::ObjectDossunNormal(const System::MapdataGeoObj &params)
7 : ObjectDossun(params) {}
8
10ObjectDossunNormal::~ObjectDossunNormal() = default;
11
13void ObjectDossunNormal::init() {
14 ObjectDossun::init();
15
16 m_stompState = StompState::Inactive;
17 m_currRot = m_rot.y;
18
19 if (m_currRot <= F_PI) {
20 m_currRot -= F_TAU;
21 }
22}
23
25void ObjectDossunNormal::calc() {
26 m_touchingGround = false;
27
28 switch (m_stompState) {
29 case StompState::Inactive:
30 calcInactive();
31 break;
32 case StompState::Active:
33 calcStomp();
34 break;
35 default:
36 break;
37 }
38}
39
41void ObjectDossunNormal::startStill() {
42 m_anmState = AnmState::Still;
43 m_shakePhase = 0;
44 m_vel = 0.0f;
45 m_flags.setBit(eFlags::Rotation);
46 m_rot.y = m_currRot;
47 m_stompState = StompState::Inactive;
48 m_stillTimer = static_cast<s32>(m_mapObj->setting(3));
49}
50
52void ObjectDossunNormal::startBeforeFall() {
53 m_stompState = StompState::Active;
54 m_anmState = AnmState::BeforeFall;
55 m_beforeFallTimer = static_cast<s32>(BEFORE_FALL_DURATION);
56 m_cycleTimer = static_cast<s32>(m_fullDuration);
57}
58
60void ObjectDossunNormal::calcInactive() {
61 constexpr s32 SHAKE_DURATION = 30;
62 constexpr s32 SHAKE_PHASE_CHANGE = 30;
63 constexpr f32 SHAKE_AMPLITUDE = 30.0f;
64
65 if (--m_stillTimer == 0) {
66 startBeforeFall();
67 }
68
69 if (m_stillTimer <= SHAKE_DURATION) {
70 m_shakePhase += SHAKE_PHASE_CHANGE;
71 m_flags.setBit(eFlags::Position);
72 m_pos.y = m_initialPosY +
73 SHAKE_AMPLITUDE * EGG::Mathf::sin(static_cast<f32>(m_shakePhase) * DEG2RAD);
74 }
75}
76
77} // namespace Field
static f32 sin(f32 x)
Definition Math.hh:37
Pertains to collision.