• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Help with game over audio

P

PlsHelpMe

Guest
I am working on a galaga style game. The player has 3 lives and dies after getting hit 3 times, but i want it to play an audio when he dies. i cant figure out how to do this and ive been to, too many forums trying to find a way to solve my problem but i havent found anything (sorry for my sloppy writing im just really tired and ive been working on this game all day). ive tried using audio_play_sound and sound_play, ive tried making it play when obj_player is destroyed and when my global variable for hp = 0. i tried to copy a line of code that i used to show the health bar when the player is alive but then show game over when it died, but replaced the code with playing music when the player is alive but then playing the game over sound effect when it dies. when the player is alive it plays the music its suppose, but not when it dies.
(thx in advance for those that help)



also heres the code

if (global.dead == false)
{
audio_play_sound(snd_game, 10, true)

} else {
sound_play(snd_game_over);

}

when global.hp = 0 then global.dead happens
 
T

Taddio

Guest
It's obvious, isnt it?
Look at your else statement.
sound_play is not even a function, unless you made a script called like that, it's audio_play_sound.
You have it right in the if statement, use the same function and syntax.
You will have to stop snd_game when snd_game_over is triggered, or they will both overlap.
 
P

PlsHelpMe

Guest
It's obvious, isnt it?
Look at your else statement.
sound_play is not even a function, unless you made a script called like that, it's audio_play_sound.
You have it right in the if statement, use the same function and syntax.
You will have to stop snd_game when snd_game_over is triggered, or they will both overlap.
I've already tried that, and it didn't work, but thanks for trying to help.
 
T

Taddio

Guest
I've already tried that, and it didn't work, but thanks for trying to help.
Put
Code:
show_debug_message("game over music ON");
in your else brackets.
Run the game in debug mode, and when your player die, check if the message shiws in the debugger.
If it does, your function is wrong, and if it doesn't, your event doesn''t trigger.
That will narrow it down for the solution.
 
P

PlsHelpMe

Guest
Put
Code:
show_debug_message("game over music ON");
in your else brackets.
Run the game in debug mode, and when your player die, check if the message shiws in the debugger.
If it does, your function is wrong, and if it doesn't, your event doesn''t trigger.
That will narrow it down for the solution.

Okay thanks. So it looks like my event doesn't trigger, do you know anyway that i could get it to trigger?
 

TheouAegis

Member
Okay thanks. So it looks like my event doesn't trigger, do you know anyway that i could get it to trigger?
First off, @Taddio, sound_play() is a valid function, but it probably only works if you disable the New Audio Engine (the one that allows you to use audio_* functions).

Second, what and where is the code that sets global.dead to true? Because if the message doesn't show up, then odds are you are never actually setting global.dead to true.

Also, where is this code running from? If the code is in the player object and you destroy the player instance when he dies, then it won't be able to run the code because the instance was already destroyed.
 
T

Taddio

Guest
First off, @Taddio, sound_play() is a valid function, but it probably only works if you disable the New Audio Engine (the one that allows you to use audio_* functions).
[My bad, I didn't realised the OP was on 1.4 and didn't know it was a build-in 1.4 function! Oops!
 
P

PlsHelpMe

Guest
First off, @Taddio, sound_play() is a valid function, but it probably only works if you disable the New Audio Engine (the one that allows you to use audio_* functions).

Second, what and where is the code that sets global.dead to true? Because if the message doesn't show up, then odds are you are never actually setting global.dead to true.

Also, where is this code running from? If the code is in the player object and you destroy the player instance when he dies, then it won't be able to run the code because the instance was already destroyed.

the code where it plays the audio when global.dead = true is in an object that i made specifically for the game over audio called obj_death_audio. Also where do I disable new audio engine? Im very new to this, and thank you for helping.
 

TheouAegis

Member
the code where it plays the audio when global.dead = true is in an object that i made specifically for the game over audio called obj_death_audio. Also where do I disable new audio engine? Im very new to this, and thank you for helping.
You set it in the game settings. But the new audio engine works fine for you obviously, since music is playing.

So, couple quick questions.So have you actually verified that global.dead is being set to true? When global.dead is set to true, you are destroying the player instance at the same time, are you not? At the time that global.dead gets set to true, do you do anything else which may prevent any other codes from running, such as restarting the room or leaving the room?
 
P

PlsHelpMe

Guest
You set it in the game settings. But the new audio engine works fine for you obviously, since music is playing.

So, couple quick questions.So have you actually verified that global.dead is being set to true? When global.dead is set to true, you are destroying the player instance at the same time, are you not? At the time that global.dead gets set to true, do you do anything else which may prevent any other codes from running, such as restarting the room or leaving the room?

global.dead does not destroy the player, but i actually found a solution to my problem and now i feel retarded. In my player object i had a step event that checked for when the player dies and then destroys the object (the step event did a few other things too). I then put in audio_play_sound(ect) and now it works, but thank you for helping me!
 
Top