Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MorsGames
GitHub Repository: MorsGames/sm64plus
Path: blob/master/src/game/behaviors/beta_trampoline.inc.c
7861 views
1
/**
2
* Behavior for bhvBetaTrampolineTop and bhvBetaTrampolineSpring.
3
* This was a trampoline that was never finished. The model and collision
4
* are nearly finished, but the code was abandoned very early on
5
* in its development. The trampoline consists of 3 objects: the top,
6
* the spring, and the base. The base is a static object with no behavior.
7
*/
8
9
/**
10
* Update function for bhvBetaTrampolineSpring.
11
* The spring continuously updates to be 75 units below the top.
12
* It then uses its displacement from its original position
13
* (i.e. how much the trampoline has compressed) to calculate its
14
* vertical scale factor, so that it compresses visually along with
15
* the trampoline. The devs were on the right track with the math,
16
* but it is incomplete.
17
*/
18
void bhv_beta_trampoline_spring_loop(void) {
19
f32 yScale;
20
f32 yDisplacement;
21
22
// Update to be 75 units under the trampoline top
23
obj_copy_pos_and_angle(o, o->parentObj);
24
obj_copy_graph_y_offset(o, o->parentObj);
25
o->oPosY -= 75.0f;
26
27
// If the trampoline top is above its original position,
28
// scale the spring by (the displacement)/10 + 1.
29
// For this to work correctly, the arbitrary value of 10
30
// must be replaced with 150 (the height of the trampoline).
31
// Note that all of the numbers in this if/else block are doubles.
32
if ((yDisplacement = o->oPosY - o->oHomeY) >= 0) {
33
yScale = yDisplacement / 10.0 + 1.0;
34
} else {
35
// Otherwise (if the trampoline is compressed),
36
// scale by 1 - (the displacement)/500.
37
// For this to work correctly, the arbitrary value of 500
38
// must be replaced with 150 (the height of the trampoline),
39
// as with the above code.
40
yDisplacement = -yDisplacement;
41
yScale = 1.0 - yDisplacement / 500.0;
42
}
43
44
// Scale the spring
45
obj_scale_xyz(o, 1.0f, yScale, 1.0f);
46
}
47
48
/**
49
* Update function for bhvBetaTrampolineTop.
50
* This spawns the other 2 trampoline parts when initialized,
51
* and sets a boolean for whether Mario's on or off the trampoline.
52
* The trampoline top never actually moves, so the spring will never
53
* do anything.
54
*/
55
void bhv_beta_trampoline_top_loop(void) {
56
cur_obj_set_model(MODEL_TRAMPOLINE);
57
58
// When initialized, spawn the rest of the trampoline
59
if (o->oTimer == 0) {
60
struct Object *trampolinePart;
61
62
trampolinePart = spawn_object(o, MODEL_TRAMPOLINE_CENTER, bhvBetaTrampolineSpring);
63
trampolinePart->oPosY -= 75.0f;
64
65
trampolinePart = spawn_object(o, MODEL_TRAMPOLINE_BASE, bhvStaticObject);
66
trampolinePart->oPosY -= 150.0f;
67
}
68
69
// Update o->oBetaTrampolineMarioOnTrampoline, and reset
70
// the trampoline's position if Mario's not on it.
71
// Since the trampoline never moves, this doesn't do anything.
72
// Maybe they intended to decrease the trampoline's position
73
// when Mario's on it in this if statement?
74
if (gMarioObject->platform == o) {
75
o->oBetaTrampolineMarioOnTrampoline = TRUE;
76
} else {
77
o->oBetaTrampolineMarioOnTrampoline = FALSE;
78
o->oPosY = o->oHomeY;
79
}
80
81
// This function is from mario_step.c, and is empty.
82
// It was probably intended to be used to "let the game know"
83
// that the trampoline is currently in use. This potential
84
// trampoline infrastructure is found in mario_step.c. See
85
// that file for more details.
86
stub_mario_step_2();
87
}
88
89