C
Crispywrists
Guest
Hello!
So in my game, once you've done a certain task it flips global.cool to 1 and you can talk to an NPC called Sporty - so every time you press E on sporty he comes out with a different short 1-2 second audio clip.
The problem is I can feel / see the game slowing down hugely the more times I press E on Sporty. It's an extreme example but when I mash E on him the frame rate goes to -61 (according to the log) and it obviously becomes unplayable, and I know when I'm stuck in a game I have been known to press E many times, so this is a problem.
My code for the action is as follows:
I assume it's something to do with the way I've coded it, or could it be something else? I hope it's glaringly obvious and you're like 'well duh you're an idiot that's a rubbish way of doing this' (but in a nicer way) and I can go back to mashing my E.
Is there a better way to code this? Or a way to flush the audio files / what's happened after each press? Is it the global variable in there?
Many thanks in advance!
So in my game, once you've done a certain task it flips global.cool to 1 and you can talk to an NPC called Sporty - so every time you press E on sporty he comes out with a different short 1-2 second audio clip.
The problem is I can feel / see the game slowing down hugely the more times I press E on Sporty. It's an extreme example but when I mash E on him the frame rate goes to -61 (according to the log) and it obviously becomes unplayable, and I know when I'm stuck in a game I have been known to press E many times, so this is a problem.
My code for the action is as follows:
I've tried fiddling around with the audio settings - they're only 200-400kb in size each so they can't really get a million times smaller, and I feel even if they did it wouldn't fix the actual problem. It's like there's a memory leak, or the actions are getting repeated over and over - the lag doesn't go away if I leave and return to the room.(In the E pressed event)
:
if (distance_to_object(obj_cliff))<30
{
if (!audio_is_playing(snd_sportycool))
&& (!audio_is_playing(snd_sporty))
&& (!audio_is_playing(snd_sporty2))
&& (!audio_is_playing(snd_sporty3))
&& (!audio_is_playing(snd_sportyambient))
{
if global.cool = true
{
audio_play_sound (choose(snd_sporty,snd_sporty2,snd_sporty3,snd_sportyambient),1,0);
}
}
}
I assume it's something to do with the way I've coded it, or could it be something else? I hope it's glaringly obvious and you're like 'well duh you're an idiot that's a rubbish way of doing this' (but in a nicer way) and I can go back to mashing my E.
Is there a better way to code this? Or a way to flush the audio files / what's happened after each press? Is it the global variable in there?
Many thanks in advance!