Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MorsGames
GitHub Repository: MorsGames/sm64plus
Path: blob/master/src/game/behaviors/bbh_tilting_trap.inc.c
7861 views
1
/**
2
* Behavior for bhvBbhTiltingTrapPlatform.
3
* This is the tilting platform trap in the upper floor of BBH
4
* that drops the player into the merry-go-round area.
5
*/
6
7
/**
8
* Update function for bhvBbhTiltingTrapPlatform.
9
*/
10
void bhv_bbh_tilting_trap_platform_loop(void) {
11
UNUSED s32 unused;
12
13
// US (and probably later) versions use oAction for the
14
// if statement, while immediately setting it over here.
15
// This was done so that Mario leaving or getting on the platform
16
// resets oTimer to 0.
17
#ifndef VERSION_JP
18
if (gMarioObject->platform == o) {
19
o->oAction = BBH_TILTING_TRAP_PLATFORM_ACT_MARIO_ON;
20
} else {
21
o->oAction = BBH_TILTING_TRAP_PLATFORM_ACT_MARIO_OFF;
22
}
23
24
if (o->oAction == BBH_TILTING_TRAP_PLATFORM_ACT_MARIO_ON) {
25
#else
26
if (gMarioObject->platform == o) {
27
#endif
28
o->oAngleVelPitch = (s32)(o->oDistanceToMario * coss(o->oAngleToMario));
29
o->oFaceAnglePitch += o->oAngleVelPitch;
30
} else
31
#ifndef VERSION_JP
32
// In the US version, if the platform has tilted more than 3000 angle units
33
// in less than 16 frames since Mario got on it, and he has stepped off,
34
// this code will not run, so it will continue to rotate with the same
35
// angular velocity for 16 more frames. This was probably done to make
36
// the platform more dangerous. This code will not work correctly
37
// without the oAction changes above, since oTimer will not ever
38
// reset to 0 without them.
39
if ((absi(o->oFaceAnglePitch) < 3000) || (o->oTimer >= 16))
40
#endif
41
{
42
// Make the platform return to the horizontal at a speed of
43
// 200 angle units/frame, and clamp it to 0 if it's within 200 units of 0.
44
o->oAngleVelPitch = 0;
45
46
if ((s16) o->oFaceAnglePitch > 0) {
47
if (o->oFaceAnglePitch < 200) {
48
o->oFaceAnglePitch = 0;
49
} else {
50
o->oAngleVelPitch = -200;
51
}
52
} else {
53
if (o->oFaceAnglePitch > -200) {
54
o->oFaceAnglePitch = 0;
55
} else {
56
o->oAngleVelPitch = 200;
57
}
58
}
59
}
60
61
// Update angle
62
o->oFaceAnglePitch += o->oAngleVelPitch;
63
}
64
65