2014-09-22 20:38:48 (edited by Orin 2014-09-22 21:35:36)

Hi all,
So, I have the following code here that's supposed to stream my Ambience; a food court in this case because I couldn't find what I wanted for this particular game idea, a machine sound which is a freezer in this case, and footstep sounds, and I should be able to walk using the left and right arrow keys, pressing escape to exit.

Of course the ambience are supposed to load and play and the footsteps play whenever the "start" variable changes, which is enitially 0.
However, seems I'm getting braces conflicts again. I fixed one, and now the compiler keeps saying "Instead there's "(" for the wait(5) function before the script is supposed to end.
I'm not sure if the use_error_output function works this time because that's only if the program successfully compiles. Anyway, here's the code. I get confused with these kind of errors because changing one line or even one brace can screw the whole script.
#include "sound_positioning.bgt"

//Sounds and grid
int start=0, mposition=40, finish=60;
sound fc;
sound fs;
sound machine;
void main()
//Stream ambience and load other sounds.
{
fc.stream("sounds/fc.ogg");
if(fc.active==false)
{
alert("Damn", "The Food Court background had a problem.");
}
fs.load("sounds/fs.wav");
if(fs.active==false)
{
alert("Damn", "The Footstep sound had a problem.");
}

machine.load("sounds/freeze.wav");
if(machine.active==false)
{
alert("Damn", "The Machine sound had a problem.");
}

show_game_window("Sidescrolling Test");

fc.play_looped();
position_sound_1d(machine, start, mposition, 1, 1);
machine.play_looped();

while(true)
{
if(key_pressed(KEY_LEFT))
{
if(start > 0)
{
start--;
position_sound_1d(machine, start, mposition, 1, 1);
fs.play();
}
}

if(key_pressed(KEY_RIGHT))
{
if(start < finish)
{
start++;
position_sound_1d(machine, start, mposition, 1, 1);
fs.play();
}
}

if(key_pressed(KEY_ESCAPE))
{
exit();
}
wait(5);
}
}

Okay, so I got it working, but unfortunately both the streaming sound and my footstep sounds are bad sounds. Why because my Ambience sound doesn't seem to loop correctly, and the footsteps sound is several slow walking steps together, not just one step. Not sure how I can edit that, was a bad sound in general but I downloaded thinking it'd be okay for a test at least. But the FC sound plays correctly once, but when it loops and attempts to play again, it gets stuck at the beginning for some odd reason. This is the same food court background sound that can be found on SoundJay.
So ugg. Would love to find sounds without editing, but is this what most devs have to do, remove unnecessary steps from, say, step sounds?
Also, I really wish the compiler gave me the right arrors. I had a quote after the left parren in the position_sound_1d function, and that was the line that needed the quote removed. However, the compiler went and told me that line 54, a right brace, was out of place and an unexpected token.

Thumbs up

2014-09-23 09:13:01

You may also want to get out of the habit of streaming sounds. I never do; I always load them. This makes there be no lag once the sound is loaded because there is no need to read the sounds from the hard drive over and over and over. I'm not sure if making the sound play whether looping a streaming sound is buggy, but I know that looping a loading sound is not. You may want to try just using.load for your food court sound, even though it's an ambience thing.

I like to sleep, Sleep is good,
This is how I do it: Lie on a nice warm cozy bed, and dream dreams about how to rule the world!
Follow @TheGreatAthlon5 on twitter for humorous facts and game updates!
If you like my posts, thumb me up!