Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MorsGames
GitHub Repository: MorsGames/sm64plus
Path: blob/master/src/game/behaviors/beta_holdable_object.inc.c
7861 views
1
/**
2
* Behavior for bhvBetaHoldableObject.
3
* This is a simple implementation of a holdable object, probably used
4
* for testing. This was previously assumed to be a beta shell, as there
5
* are unused shell models left in the game; however, there is no evidence
6
* to support this theory.
7
*/
8
9
/**
10
* Initialization function for bhvBetaHoldableObject.
11
* Just sets various physics constants for the object.
12
*/
13
void bhv_beta_holdable_object_init(void) {
14
o->oGravity = 2.5;
15
o->oFriction = 0.8;
16
o->oBuoyancy = 1.3;
17
}
18
19
/**
20
* Drop the object.
21
*/
22
static void beta_holdable_object_drop(void) {
23
// Re-enable rendering
24
cur_obj_enable_rendering();
25
26
cur_obj_get_dropped();
27
28
o->oHeldState = HELD_FREE;
29
30
o->oForwardVel = 0;
31
o->oVelY = 0;
32
}
33
34
/**
35
* Throw the object.
36
*/
37
static void beta_holdable_object_throw(void) {
38
// cur_obj_enable_rendering_2 just calls cur_obj_enable_rendering and does
39
// nothing else; it's useless here. Maybe it originally did more?
40
cur_obj_enable_rendering_2();
41
cur_obj_enable_rendering();
42
43
o->oHeldState = HELD_FREE;
44
45
// This flag is never set, why is it cleared?
46
o->oFlags &= ~OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW;
47
48
// Set initial velocity
49
o->oForwardVel = 40.0;
50
o->oVelY = 20.0;
51
}
52
53
/**
54
* Update function for bhvBetaHoldableObject.
55
* Apply standard physics to the object if not held;
56
* otherwise, handle holding logic.
57
*/
58
void bhv_beta_holdable_object_loop(void) {
59
switch (o->oHeldState) {
60
case HELD_FREE:
61
// Apply standard physics
62
object_step();
63
break;
64
65
case HELD_HELD:
66
// Disable rendering to hide the object while it's held
67
cur_obj_disable_rendering();
68
break;
69
70
case HELD_THROWN:
71
beta_holdable_object_throw();
72
break;
73
74
case HELD_DROPPED:
75
beta_holdable_object_drop();
76
break;
77
}
78
}
79
80