Skip to content

Commit

Permalink
add special effect to associate a sound with jumping.
Browse files Browse the repository at this point in the history
  • Loading branch information
gabordemooij committed Nov 20, 2024
1 parent 83625bd commit a3ac003
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions plugins/media/media.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#define CTR_MEDIA_FX_FLAG_MEDIA_TEST 0
#define CTR_MEDIA_FX_FLAG_MEDIA_REMAP_ALL 1
#define CTR_MEDIA_FX_FLAG_AUDIO_JUMP 2000


uint64_t CtrMediaTicks1 = 0;
Expand Down Expand Up @@ -185,7 +186,12 @@ uint8_t CtrMediaEventListenFlagGamePadBtnDown;
uint8_t CtrMediaEventListenFlagTimer;
uint8_t CtrMediaEventListenFlagStep;

// FX flags
int CtrMediaFXFlagMapABXY2Up;
int CtrMediaFXFlagJumpSFX;

// FX data
ctr_object* CtrMediaFXFlagJumpSound;


void ctr_internal_img_render_text(ctr_object* myself);
Expand Down Expand Up @@ -980,6 +986,12 @@ void ctr_internal_media_keydown_up(int* dir, int* c4speed) {
if (player->gravity >= 1 && CtrMediaControlMode == 1) {
if (CtrMediaJump == 0) {
CtrMediaJump = 1;
if (CtrMediaFXFlagJumpSFX && CtrMediaFXFlagJumpSound) {
MediaAUD* jumpsound = ctr_internal_get_audio_from_object(CtrMediaFXFlagJumpSound);
if (jumpsound) {
Mix_PlayChannel(1, (Mix_Chunk*) jumpsound->blob, 0);
}
}
}
}
else if ((CtrMediaControlMode == 1 || CtrMediaControlMode == 2)) {
Expand Down Expand Up @@ -4438,6 +4450,13 @@ ctr_object* ctr_media_fx(ctr_object* myself, ctr_argument* argumentList) {
// other options might be added later...
CtrMediaFXFlagMapABXY2Up = ctr_tonum(data);
}
else if (fx_code == CTR_MEDIA_FX_FLAG_AUDIO_JUMP) {
// associate a sound object with jumping in platform mode
// regardless of device (key, gamepad, touch) on a separate
// audio channel.
CtrMediaFXFlagJumpSFX = ctr_tonum(data);
CtrMediaFXFlagJumpSound = argumentList->next->object;
}
return myself;
}

Expand Down

0 comments on commit a3ac003

Please sign in to comment.