2017-05-28 13:52:48

Hello everyone,

I'm trying to develop a small game in BGT, in which I need to announce the row and column numbers of each cell when you use arrows to move in the grib. Something like 5, 8. The problem is with interrupting the numbers when the player is moving rapidly on the grid. My solution is this function I wrote that doesn't work very smoothly:

void PlayCell()
{
sound SayX, SayY;
SayX.load("Voices/" + x + ".wav");
SayY.load("Voices/" + y + ".wav");

SayX.play();

while (SayX.playing)
{
if (key_pressed(KEY_LEFT) || key_pressed(KEY_RIGHT) || key_pressed(KEY_UP) || key_pressed(KEY_DOWN))
{
SayX.stop();
return;
}

wait(5);
}

SayY.play();

while (SayY.playing)
{
if (key_pressed(KEY_LEFT) || key_pressed(KEY_RIGHT) || key_pressed(KEY_UP) || key_pressed(KEY_DOWN))
{
SayY.stop();
return;
}

wait(5);
}
}

Isn't there a better way? For example, isn't it possible to merge two sounds in one sound object? So for example, I can merge 5 and 8 to one sound object and play it without so much fuss?
Thanks in advance.

Cheers,
  Meisam

2017-05-28 14:04:50

You might consider the number_speaker, which is in the helper layer in the manual. This sounds like the exact situation it works well with.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.