Platform Builder Forums

Main => Suggestions => Topic started by: saiwong3268 on December 05, 2019, 07:01:46 PM

Title: Oxygen Level
Post by: saiwong3268 on December 05, 2019, 07:01:46 PM
I am working on a water area. However, what I've found is that I am too focused on avoiding enemies that I forget to check my oxygen level and die through lack of air.

Can you implement a way that
when low on oxygen to get some sort of ALARM sound ? (The alarm sound can turn off when you
go up to the surface or get enough oxygen through bubbles).
Title: Re: Oxygen Level
Post by: Gizgord on December 05, 2019, 07:13:33 PM
find an option "Loop Command" and try something like this:
if air < x
{
play sfx = y
loop = staggered
}

where x describes what number do you want your alarm to start, and y stands for a sound effect used.

"loop = staggered" does an action every 5 frames, so that might be too fast. I think it'll work, but you don't know untill you check. :)
Title: Re: Oxygen Level
Post by: CGM on December 05, 2019, 07:23:11 PM
I'm not sure if that will work. I wondered if that might work, but I doubt it. It's worth a shot though!
Title: Re: Oxygen Level
Post by: Gizgord on December 05, 2019, 07:42:24 PM
it does not, you hear this alarm above water. I tried:

if swimming = true
and if breath < 5
{
sfx = 5
loop = staggered
}

seems like it should work, but it doesn't. maybe you need to use a timeline.
Title: Re: Oxygen Level
Post by: CGM on December 05, 2019, 07:48:19 PM
The and conditional is incorrect. It should be & breath <5. And I didn't think you could cause commands to loop by doing loop=staggered.
Title: Re: Oxygen Level
Post by: Gizgord on December 05, 2019, 08:12:07 PM
The and conditional is incorrect. It should be & breath <5. And I didn't think you could cause commands to loop by doing loop=staggered.
I'm reading all commands from the page, and both "and breath <5" and "loop=staggered" are written down.
Title: Re: Oxygen Level
Post by: CGM on December 05, 2019, 08:15:51 PM
I wasn't aware of the breath command. And I'm aware of the loop constant and staggered commands. I just didn't know that it'd loop commands you wrote down. I thought it only worked in area beginning commands.
Title: Re: Oxygen Level
Post by: Gizgord on December 05, 2019, 08:25:29 PM
that may be the case. either way, I can't get it to work. not great with commands. :P
Title: Re: Oxygen Level
Post by: saiwong3268 on December 05, 2019, 10:37:52 PM
I was looking at the command line tutorial

https://theplatformbuilder.com/Conditionals/


maybe try:

if swimming = true &  breath < 5
{
sfx = 5
loop = staggered
}


does this work ?
Title: Re: Oxygen Level
Post by: CGM on December 06, 2019, 12:17:42 AM
It might! Try it out and loop it in the loop command for the sandbox level. Find it by clicking settings. I believe it's at the top right.
Title: Re: Oxygen Level
Post by: War on December 06, 2019, 06:53:54 AM
Creepy memories from Sonic 1...
Title: Re: Oxygen Level
Post by: saiwong3268 on December 06, 2019, 11:35:45 AM
I finally got it to work with the following:

if swimming = true
{
if breath < 3000
{
sfx = 5
loop = staggered
}
}
Title: Re: Oxygen Level
Post by: Gizgord on December 06, 2019, 12:10:28 PM
really, it does work?
you're a Mastermind, that's what you are.  :o  ;)
Title: Re: Oxygen Level
Post by: War on December 07, 2019, 08:22:16 PM
I finally got it to work with the following:

if swimming = true
{
if breath < 3000
{
sfx = 5
loop = staggered
}
}
Good job! Antikore should be proud of you!
(and a bunch of Sonic fans should be eternally grateful to you ;))
Title: Re: Oxygen Level
Post by: CGM on December 07, 2019, 11:16:42 PM
??? I'm not sure how to interpret that.
Title: Re: Oxygen Level
Post by: saiwong3268 on December 08, 2019, 11:02:37 PM
I have been testing my Sandbox levels and noticed that the swimming alarm code works for 99%
of the situations. However, there was an issue when your characters head is above water whilst
the characters feet are underwater.

I investigated the issue, and concluded that if your character is not swimming,
the value of breath/air is "undefined" (believe it is something like  -1)

The issue is when your character is swimming, but has head above water, value of
swimming is true, but breath is "undefined" so alarm sounds

In order to fix this, use the following:

if swimming = true  & breath > 0
{
if breath < 3000
{
sfx = 5
loop = staggered
}
}


You can interpret the first 'if statement' as:   if character is swimming and breath value is defined
Title: Re: Oxygen Level
Post by: TingThing on December 30, 2019, 04:42:46 AM
don't forget that you could use a variable with a delay command or a looping timeline to loop stuff at your own pace.
Title: Re: Oxygen Level
Post by: CGM on December 30, 2019, 06:47:09 PM
Could you explain that, TingThing?
Title: Re: Oxygen Level
Post by: TingThing on December 30, 2019, 10:53:33 PM

You guys have talked about doing staggered looping so that the sound effect doesn't play as frequently. But it will still loop quite quickly.

if swimming = true  & breath > 0
{
if breath < 3000
{
sfx = 5
loop = staggered
}
}


Thing is, you could just put that into a timeline that loops itself every second. That way the sound effect will only happen every second when the breath amount is low.