Added Various Sounds to Game

- intercom on sound triggers when its the first queued sound
- intercom off sound triggers when its the last queued sound in a string of sounds
- button press sound implemented
- cube dropper now has a sound when it drops cube
- pedestal now has a shooting sound
This commit is contained in:
Weston Salinas 2023-03-14 15:34:34 -05:00
parent 1f2992fbb6
commit ef476af8a3
15 changed files with 71 additions and 3 deletions

View file

@ -0,0 +1 @@
-c 1 -r 22050

View file

@ -0,0 +1 @@
-c 1 -r 22050

View file

@ -0,0 +1 @@
-c 1 -r 22050

View file

@ -0,0 +1 @@
-c 1 -r 22050

View file

@ -0,0 +1 @@
-c 1

View file

@ -32,6 +32,14 @@ unsigned short soundsSelecting[3] = {
SOUNDS_SUIT_DENYDEVICE,
};
unsigned short soundsIntercom[2] = {
SOUNDS_DING_ON,
SOUNDS_DING_OFF,
};
unsigned short soundsButton = SOUNDS_BUTTON3;
unsigned short soundsReleaseCube = SOUNDS_DOORMOVE2;
unsigned short soundsPedestalShooting = SOUNDS_CHARGING;
unsigned short soundsPortalOpen2 = SOUNDS_PORTAL_OPEN2;
unsigned short soundsPortalFizzle = SOUNDS_PORTAL_FIZZLE2;

View file

@ -7,6 +7,11 @@ extern unsigned short soundsPortalExit[2];
extern unsigned short soundsPortalgunShoot[2];
extern unsigned short soundsConcreteFootstep[4];
extern unsigned short soundsSelecting[3];
extern unsigned short soundsIntercom[2];
extern unsigned short soundsButton;
extern unsigned short soundsReleaseCube;
extern unsigned short soundsPedestalShooting;
extern unsigned short soundsPortalOpen2;

View file

@ -10,7 +10,7 @@
struct CutsceneRunner* gRunningCutscenes;
struct CutsceneRunner* gUnusedRunners;
#define MAX_QUEUE_LENGTH 16
#define MAX_QUEUE_LENGTH 25
struct QueuedSound {
struct QueuedSound* next;
@ -122,6 +122,19 @@ float cutsceneRunnerConvertPlaybackSpeed(s8 asInt) {
void cutsceneRunnerStartStep(struct CutsceneRunner* runner) {
struct CutsceneStep* step = &runner->currentCutscene->steps[runner->currentStep];
struct CutsceneStep* prev_step;
struct CutsceneStep* next_step;
enum CutsceneStepType prev_type = -1;
enum CutsceneStepType next_type = -1;
if (runner->currentStep != 0){
prev_step = &runner->currentCutscene->steps[(runner->currentStep)-1];
prev_type = prev_step->type;
}
if (runner->currentStep < runner->currentCutscene->stepCount){
next_step = &runner->currentCutscene->steps[(runner->currentStep)+1];
next_type = next_step->type;
}
switch (step->type) {
case CutsceneStepTypePlaySound:
case CutsceneStepTypeStartSound:
@ -134,8 +147,16 @@ void cutsceneRunnerStartStep(struct CutsceneRunner* runner) {
);
break;
case CutsceneStepTypeQueueSound:
{
if ((prev_type == -1) || !(prev_type == CutsceneStepTypeQueueSound)){
cutsceneQueueSound(soundsIntercom[0], step->queueSound.volume * (1.0f / 255.0f), step->queueSound.channel);
}
cutsceneQueueSound(step->queueSound.soundId, step->queueSound.volume * (1.0f / 255.0f), step->queueSound.channel);
if ((next_type == -1) || !(next_type == CutsceneStepTypeQueueSound)){
cutsceneQueueSound(soundsIntercom[1], step->queueSound.volume * (1.0f / 255.0f), step->queueSound.channel);
}
break;
}
case CutsceneStepTypeDelay:
runner->state.delay = step->delay;
break;

View file

@ -3,7 +3,7 @@
#include <ultra64.h>
#include "level_definition.h"
#include "../audio/clips.h"
union CutsceneStepState {
struct {
ALSndId soundId;

View file

@ -144,6 +144,7 @@ void boxDropperUpdate(struct BoxDropper* dropper) {
decorObjectInit(&dropper->activeCube, decorObjectDefinitionForId(DECOR_TYPE_CUBE_UNIMPORTANT), &pendingCubePos, dropper->roomIndex);
skAnimatorRunClip(&dropper->animator, &props_box_dropper_Armature_DropCube_clip, 0.0f, 0);
soundPlayerPlay(soundsReleaseCube, 5.0f, 0.5f, &dropper->activeCube.rigidBody.transform.position, &gZeroVec);
dropper->flags &= ~BoxDropperFlagsCubeRequested;
dropper->flags |= BoxDropperFlagsCubeIsActive;

View file

@ -5,6 +5,8 @@
#include "../sk64/skelatool_armature.h"
#include "../sk64/skelatool_animator.h"
#include "../levels/level_definition.h"
#include "../audio/clips.h"
#include "../audio/soundplayer.h"
#include "../decor/decor_object.h"

View file

@ -36,6 +36,8 @@ struct ColliderTypeData gButtonCollider = {
&gCollisionCylinderCallbacks
};
int gPrevButtonState = 0; //0 == unpressed, 1 == pressed
#define MASS_BUTTON_PRESS_THRESHOLD 1.9f
#define BUTTON_MOVEMENT_AMOUNT 0.1f
#define BUTTON_MOVE_VELOCTY 0.3f
@ -93,11 +95,11 @@ void buttonUpdate(struct Button* button) {
struct ContactManifold* manifold = contactSolverNextManifold(&gContactSolver, &button->collisionObject, NULL);
int shouldPress = 0;
while (manifold) {
struct CollisionObject* other = manifold->shapeA == &button->collisionObject ? manifold->shapeB : manifold->shapeA;
if (other->body && other->body->mass > MASS_BUTTON_PRESS_THRESHOLD) {
shouldPress = 1;
if (other->body->flags & RigidBodyFlagsGrabbable) {
@ -110,6 +112,7 @@ void buttonUpdate(struct Button* button) {
manifold = contactSolverNextManifold(&gContactSolver, &button->collisionObject, manifold);
}
if (button->collisionObject.flags & COLLISION_OBJECT_PLAYER_STANDING) {
button->collisionObject.flags &= ~COLLISION_OBJECT_PLAYER_STANDING;
shouldPress = 1;
@ -118,6 +121,8 @@ void buttonUpdate(struct Button* button) {
struct Vector3 targetPos = button->originalPos;
if (shouldPress) {
targetPos.y -= BUTTON_MOVEMENT_AMOUNT;
signalsSend(button->signalIndex);
@ -126,8 +131,22 @@ void buttonUpdate(struct Button* button) {
}
}
//if its actively moving up or down
if (targetPos.y != button->rigidBody.transform.position.y) {
//actively going down
if (shouldPress){
if (gPrevButtonState == 0){
soundPlayerPlay(soundsButton, 2.5f, 0.5f, &button->rigidBody.transform.position, &gZeroVec);
}
gPrevButtonState = 1;
}
// actively going up
else{
gPrevButtonState = 0;
}
vector3MoveTowards(&button->rigidBody.transform.position, &targetPos, BUTTON_MOVE_VELOCTY * FIXED_DELTA_TIME, &button->rigidBody.transform.position);
collisionObjectUpdateBB(&button->collisionObject);
}
}

View file

@ -4,6 +4,8 @@
#include "../physics/collision_object.h"
#include "signals.h"
#include "../levels/level_definition.h"
#include "../audio/clips.h"
#include "../audio/soundplayer.h"
struct Button {
struct CollisionObject collisionObject;

View file

@ -89,6 +89,9 @@ void pedestalUpdate(struct Pedestal* pedestal) {
pedestalDetermineHolderAngle(pedestal, &target);
if (vector2RotateTowards(&pedestal->currentRotation, &target, &gMaxPedistalRotation, &pedestal->currentRotation)) {
if (!(pedestal->flags & PedestalFlagsDown)){
soundPlayerPlay(soundsPedestalShooting, 5.0f, 0.5f, &pedestal->transform.position, &gZeroVec);
}
pedestal->flags &= ~PedestalFlagsIsPointing;
}
}

View file

@ -4,6 +4,8 @@
#include "../sk64/skelatool_armature.h"
#include "../sk64/skelatool_animator.h"
#include "../levels/level_definition.h"
#include "../audio/soundplayer.h"
#include "../audio/clips.h"
enum PedestalFlags {
PedestalFlagsDown = (1 << 0),