Path: blob/master/src/game/behaviors/beta_trampoline.inc.c
7861 views
/**1* Behavior for bhvBetaTrampolineTop and bhvBetaTrampolineSpring.2* This was a trampoline that was never finished. The model and collision3* are nearly finished, but the code was abandoned very early on4* in its development. The trampoline consists of 3 objects: the top,5* the spring, and the base. The base is a static object with no behavior.6*/78/**9* Update function for bhvBetaTrampolineSpring.10* The spring continuously updates to be 75 units below the top.11* It then uses its displacement from its original position12* (i.e. how much the trampoline has compressed) to calculate its13* vertical scale factor, so that it compresses visually along with14* the trampoline. The devs were on the right track with the math,15* but it is incomplete.16*/17void bhv_beta_trampoline_spring_loop(void) {18f32 yScale;19f32 yDisplacement;2021// Update to be 75 units under the trampoline top22obj_copy_pos_and_angle(o, o->parentObj);23obj_copy_graph_y_offset(o, o->parentObj);24o->oPosY -= 75.0f;2526// If the trampoline top is above its original position,27// scale the spring by (the displacement)/10 + 1.28// For this to work correctly, the arbitrary value of 1029// must be replaced with 150 (the height of the trampoline).30// Note that all of the numbers in this if/else block are doubles.31if ((yDisplacement = o->oPosY - o->oHomeY) >= 0) {32yScale = yDisplacement / 10.0 + 1.0;33} else {34// Otherwise (if the trampoline is compressed),35// scale by 1 - (the displacement)/500.36// For this to work correctly, the arbitrary value of 50037// must be replaced with 150 (the height of the trampoline),38// as with the above code.39yDisplacement = -yDisplacement;40yScale = 1.0 - yDisplacement / 500.0;41}4243// Scale the spring44obj_scale_xyz(o, 1.0f, yScale, 1.0f);45}4647/**48* Update function for bhvBetaTrampolineTop.49* This spawns the other 2 trampoline parts when initialized,50* and sets a boolean for whether Mario's on or off the trampoline.51* The trampoline top never actually moves, so the spring will never52* do anything.53*/54void bhv_beta_trampoline_top_loop(void) {55cur_obj_set_model(MODEL_TRAMPOLINE);5657// When initialized, spawn the rest of the trampoline58if (o->oTimer == 0) {59struct Object *trampolinePart;6061trampolinePart = spawn_object(o, MODEL_TRAMPOLINE_CENTER, bhvBetaTrampolineSpring);62trampolinePart->oPosY -= 75.0f;6364trampolinePart = spawn_object(o, MODEL_TRAMPOLINE_BASE, bhvStaticObject);65trampolinePart->oPosY -= 150.0f;66}6768// Update o->oBetaTrampolineMarioOnTrampoline, and reset69// the trampoline's position if Mario's not on it.70// Since the trampoline never moves, this doesn't do anything.71// Maybe they intended to decrease the trampoline's position72// when Mario's on it in this if statement?73if (gMarioObject->platform == o) {74o->oBetaTrampolineMarioOnTrampoline = TRUE;75} else {76o->oBetaTrampolineMarioOnTrampoline = FALSE;77o->oPosY = o->oHomeY;78}7980// This function is from mario_step.c, and is empty.81// It was probably intended to be used to "let the game know"82// that the trampoline is currently in use. This potential83// trampoline infrastructure is found in mario_step.c. See84// that file for more details.85stub_mario_step_2();86}878889