decorative_pendulum.inc.c (955B)
1 2 /** 3 * Behavior for bhvDecorativePendulum. 4 * This controls the pendulum that lies underneath the Tick Tock Clock painting. 5 */ 6 7 void bhv_decorative_pendulum_init(void) { 8 o->oAngleVelRoll = 0x100; 9 bhv_init_room(); 10 } 11 12 /** 13 * Smoothly swing the decorative pendulum back and forth using constant angular 14 * acceleration. 15 */ 16 void bhv_decorative_pendulum_loop(void) { 17 if (o->oFaceAngleRoll > 0) { 18 o->oAngleVelRoll -= 0x08; 19 } else { 20 o->oAngleVelRoll += 0x08; 21 } 22 23 o->oFaceAngleRoll += o->oAngleVelRoll; 24 25 /** 26 * This if-statement is true twice in the span of 5 frames when 27 * oAngleVelRoll takes values in {0x10, 0x08, 0x00, -0x08, -0x10}. 28 * This means the sound we hear when the pendulum hits its upswing is 29 * actually one sound played twice in rapid succession. 30 */ 31 if (o->oAngleVelRoll == 0x10 || o->oAngleVelRoll == -0x10) { 32 cur_obj_play_sound_2(SOUND_GENERAL_BIG_CLOCK); 33 } 34 }