sm64

A Super Mario 64 decompilation
Log | Files | Refs | README | LICENSE

ferris_wheel.inc.c (2286B)


      1 
      2 /**
      3  * Behaviors for bhvFerrisWheelAxle and bhvFerrisWheelPlatform.
      4  * These are the revolving sets of four platforms in BitDW and BitS.
      5  * The axle spawns the four platforms.
      6  */
      7 
      8 /**
      9  * Properties for the ferris wheel axle and platforms.
     10  */
     11 struct FerrisWheelProperties {
     12     Collision const *axleCollision;
     13     Collision const *platformCollision;
     14     s16 platformModel;
     15 };
     16 
     17 /**
     18  * Properties for the ferris wheels in BitS and BitDW, respectively.
     19  */
     20 static struct FerrisWheelProperties sFerrisWheelProperties[] = {
     21     { bits_seg7_collision_0701ACAC, bits_seg7_collision_0701AC28, MODEL_BITS_BLUE_PLATFORM },
     22     { bitdw_seg7_collision_0700F7F0, bitdw_seg7_collision_0700F898, MODEL_BITDW_BLUE_PLATFORM },
     23 };
     24 
     25 /**
     26  * Init function for bhvFerrisWheelAxle.
     27  * It doesn't have an update function, but it increments its roll in its
     28  * behavior script.
     29  */
     30 void bhv_ferris_wheel_axle_init(void) {
     31     struct Object *platform;
     32     s32 i;
     33 
     34     o->collisionData =
     35         segmented_to_virtual(sFerrisWheelProperties[o->oBhvParams2ndByte].axleCollision);
     36 
     37     for (i = 0; i < 4; i++) {
     38         platform = spawn_object_relative(i, 0, 0, 0, o,
     39                                          sFerrisWheelProperties[o->oBhvParams2ndByte].platformModel,
     40                                          bhvFerrisWheelPlatform);
     41 
     42         if (platform != NULL) {
     43             platform->collisionData =
     44                 segmented_to_virtual(sFerrisWheelProperties[o->oBhvParams2ndByte].platformCollision);
     45         }
     46     }
     47 }
     48 
     49 /**
     50  * Update function for bhvFerrisWheelPlatform.
     51  * Position self relative to parent using the parent's roll.
     52  */
     53 void bhv_ferris_wheel_platform_update(void) {
     54     f32 offsetXZ;
     55     s16 offsetAngle;
     56 
     57     obj_perform_position_op(POS_OP_SAVE_POSITION);
     58 
     59     offsetAngle = o->parentObj->oFaceAngleRoll + o->oBhvParams2ndByte * 0x4000;
     60     offsetXZ = 400.0f * coss(offsetAngle);
     61 
     62     o->oPosX = o->parentObj->oPosX + offsetXZ * sins(o->parentObj->oMoveAngleYaw)
     63                + 300.0f * coss(o->parentObj->oMoveAngleYaw);
     64 
     65     o->oPosY = o->parentObj->oPosY + 400.0f * sins(offsetAngle);
     66 
     67     o->oPosZ = o->parentObj->oPosZ + offsetXZ * coss(o->parentObj->oMoveAngleYaw)
     68                + 300.0f * sins(o->parentObj->oMoveAngleYaw);
     69 
     70     obj_perform_position_op(POS_OP_COMPUTE_VELOCITY);
     71 }