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