A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectDossun.hh
1#pragma once
2
3#include "game/field/obj/ObjectCollidable.hh"
4
5namespace Field {
6
12public:
14 ~ObjectDossun() override;
15
16 void init() override;
17
18 [[nodiscard]] u32 loadFlags() const override {
19 return 1;
20 }
21
22 void calcCollisionTransform() override;
23 Kart::Reaction onCollision(Kart::KartObject *kartObj, Kart::Reaction reactionOnKart,
24 Kart::Reaction reactionOnObj, EGG::Vector3f &hitDepth) override;
25
26 void initState();
27 void calcStomp();
28
30 virtual void startStill() {
31 m_anmState = AnmState::Still;
32 m_shakePhase = 0;
33 m_vel = 0.0f;
34 m_flags.setBit(eFlags::Rotation);
35 m_rot.y = m_currRot;
36 }
37
39 void startGrounded() {
40 m_anmState = AnmState::Grounded;
41 m_groundedTimer = GROUND_DURATION;
42 }
43
44protected:
46 enum class AnmState {
47 Still = 0,
48 BeforeFall = 1,
49 Falling = 2,
50 Grounded = 3,
51 Rising = 4,
52 };
53
54 enum class StompState {
55 Inactive = 0,
56 Active = 1,
57 };
58
59 StompState m_stompState;
60 AnmState m_anmState;
65 f32 m_vel;
66 f32 m_initialPosY;
68 s32 m_cycleTimer;
69 f32 m_currRot;
70 bool m_touchingGround;
71
73 static constexpr u32 BEFORE_FALL_DURATION = 10;
74
75private:
76 void calcBeforeFall();
77 void calcFalling();
78
80 void calcGrounded() {
81 if (--m_groundedTimer == 0) {
82 m_anmState = AnmState::Rising;
83 }
84 }
85
87 void calcRising() {
88 m_pos.y = std::min(RISING_VEL + m_pos.y, m_initialPosY);
89 m_flags.setBit(eFlags::Position);
90 }
91
92 void checkFloorCollision();
93
94 static constexpr u32 GROUND_DURATION = 60;
95 static constexpr u32 STOMP_ACCEL = 17.0f;
96 static constexpr f32 STOMP_RADIUS = 20.0f;
97 static constexpr EGG::Vector3f STOMP_POS_OFFSET = EGG::Vector3f(0.0f, STOMP_RADIUS, 0.0f);
98 static constexpr f32 RISING_VEL = 10.0f;
99};
100
101} // namespace Field
Base class for the various different Thwomp types in the game.
AnmState
Represents the current movement state of the Thwomp in terms of its stomp.
@ BeforeFall
The quick upwards motion before slamming down.
@ Grounded
Contacting the floor.
static constexpr u32 BEFORE_FALL_DURATION
The total number of frames the thwomp rises before crashing down.
s32 m_shakePhase
Causes the Thwomp's position to shake at the end of the "still" state.
s32 m_beforeFallTimer
Number of frames until the Thwomp will stomp down.
s32 m_stillTimer
Number of frames the Thwomp will remain stationary (or shakes)
f32 m_vel
Vector3f in the base game, but only the y-component is used.
u32 m_fullDuration
Framecount of an entire animation loop.
s32 m_groundedTimer
Number of frames the Thwomp remains on the ground.
The highest level abstraction for a kart.
Definition KartObject.hh:11
Pertains to collision.
constexpr TBitFlag< T, E > & setBit(Es... es)
Sets the corresponding bits for the provided enum values.
Definition BitFlag.hh:62
A 3D float vector.
Definition Vector.hh:88