Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
3 registered members (Martin_HH, steyr, alibaba), 509 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
sound loop #115362
03/05/07 19:30
03/05/07 19:30
Joined: Jul 2002
Posts: 857
Québec
Marky Mark Offline OP
User
Marky Mark  Offline OP
User

Joined: Jul 2002
Posts: 857
Québec
Hey,

Here's my rain sound function. I want to start a loop in a certain moment, so i placed the snd_loop in a function that will be called later...

here it is:

Code:

function rain_play()
{
if (snd_playing(rainloopnice) == 1)
{
wait(1);
}
if (snd_playing(rainloopnice) == 0)
{
snd_loop (rainloopnice, 80, 0);
}
}



Heres my other function, the one that calls rain_play()

Code:

while(1)
{
if (vec_dist(my.x, player.x) < my.skill1)
{
if (ObservationConditions == ocAverage)
{
rainit();
rain_play();
}
if (ObservationConditions == ocGood)
{
rainit();
rain_play();
}
}
else
{
// No Rain...
}
wait(1);
}
Code:


When I run my game, it works, but it seems like the sound is playing 200 times
so it looks like a robotic rain sound mixed with a "your computer will crash soon" .. any ideas? thanks

Last edited by Marky Mark; 03/05/07 19:30.

Yeah! IE sucks, use Mozilla...
Marc Rémillard.
Re: sound loop [Re: Marky Mark] #115363
03/05/07 20:26
03/05/07 20:26
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
I guess "rainloopnice" is a sound defined this way:
sound rainloopnice = <source.fileType>; ?

If yes:
snd_playing() is expecting a handle of a sound, not the sound itself.
You need to define a var which stores the handle to that sound:
Code:

var rainloop_handle;
//...
if(snd_playing(rainloop_handle))
{
return;
}
else
{
rainloop_handle = snd_loop(rainloopnice,80,0);
}
//...



Re: sound loop [Re: Xarthor] #115364
03/05/07 20:50
03/05/07 20:50
Joined: Jul 2002
Posts: 857
Québec
Marky Mark Offline OP
User
Marky Mark  Offline OP
User

Joined: Jul 2002
Posts: 857
Québec
Yeah its defined this way. I'll give a try. thanks

Last edited by Marky Mark; 03/05/07 21:20.

Yeah! IE sucks, use Mozilla...
Marc Rémillard.
Re: sound loop [Re: Marky Mark] #115365
03/05/07 21:26
03/05/07 21:26
Joined: Jul 2002
Posts: 857
Québec
Marky Mark Offline OP
User
Marky Mark  Offline OP
User

Joined: Jul 2002
Posts: 857
Québec
Thanks it works!!

Now, to stop it, i just have to do snd_stop(handle) ?


Yeah! IE sucks, use Mozilla...
Marc Rémillard.
Re: sound loop [Re: Marky Mark] #115366
03/05/07 22:40
03/05/07 22:40
Joined: Jul 2002
Posts: 857
Québec
Marky Mark Offline OP
User
Marky Mark  Offline OP
User

Joined: Jul 2002
Posts: 857
Québec
I want to stop the rain sound and my particle effect when i'm out of the distance... it won't work.. look at my code:

Thanks to help!

bmap rainitBmap = <drop.tga>;
VAR rainitAnzahlPartikel = 9; //number of particles used for this effect
sound rainloopnice = <rainl.wav>;
var rainturnoff = 0;



Function rainit_spec_fun()
{
my.alpha -= -13.770 *time;
IF(My.alpha < 0) { my.alpha = 0; my.lifespan = 0; }
my.skill_b += 0.03;
my.skill_c = 6 - my.skill_b;
if(my.skill_c < 0) { my.lifespan = 0; }
if (rainturnoff == 1) { my.lifespan = 0; }
}

Function rainitspezial()
{
my.blue = 128 ;
my.green = 128 ;
my.red = 128 ;
my.skill_c = 0; my.skill_b = 0;
my.bmap = rainitBmap; //the effect bitmap
my.vel_x = random( 0 ) - 0 ;
my.vel_y = random( 0 ) - 0 ;
my.vel_z = -40 ;
my.size = 14 ;
my.alpha = 46.375 ;
my.x += random(5000)-500; //2000 2000 500
my.y += random(5000)-500;
my.z += random(2000)-50;
my.gravity = 0 ;
my.streak = off;
my.flare = on;
my.bright = on;
my.beam = off;
my.move = on;
my.transparent = on;
my.function = rainit_spec_fun;
}


Function rainit()
{
while(1)
{
rainitAnzahlPartikel = 38;
var myPos[3];
vec_set(myPOS,camera.x);
temp.x = COS(camera.pan);
temp.y = SIN(camera.pan);
temp.Z = 600*COS(camera.tilt);
MyPos.X = myPos.X + temp.Z*temp.X;
MyPos.Y = myPos.Y + temp.Z*temp.Y;;
MyPos.Z = myPos.Z + 600*SIN(camera.TILT); //600
MyPos.Z = Camera.Z + 800; //800
effect(rainitspezial,max(1,int(rainitAnzahlPartikel*time)),MyPOS,nullvector);
wait(1);
}
}






var rainloop_handle;

action rainthatshit
{
// Range to scan for rain...
my.skill1 = 4000;
//
while(1)
{
if (vec_dist(my.x, player.x) < my.skill1)
{
if (ObservationConditions == ocAverage)
{
rainit();
if(snd_playing(rainloop_handle))
{
return;
}
else
{
rainloop_handle = snd_loop(rainloopnice,15,0);
rainturnoff = 0;
}
}
if (ObservationConditions == ocGood)
{
rainit();
if(snd_playing(rainloop_handle))
{
return;
}
else
{
rainloop_handle = snd_loop(rainloopnice,15,0);
rainturnoff = 0;
}
}
}
else
{
stopit();
}
wait(1);
}
}

function stopit()
{
snd_stop(rainloop_handle);
rainturnoff = 1;
}



Yeah! IE sucks, use Mozilla...
Marc Rémillard.
Re: sound loop [Re: Marky Mark] #115367
03/06/07 00:29
03/06/07 00:29
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Take out the while(1) out of rain_init().

This is causing it to keep running


xXxGuitar511
- Programmer
Re: sound loop [Re: xXxGuitar511] #115368
03/06/07 15:43
03/06/07 15:43
Joined: Jul 2002
Posts: 857
Québec
Marky Mark Offline OP
User
Marky Mark  Offline OP
User

Joined: Jul 2002
Posts: 857
Québec
First, it's rainit() , and i tried, but when i remove the while(1), i can see that it starts raining for a first bunch of particles, but then after those particles, nothing. So i guess i have to place the while(1) in this function, but maybe there's something else to add to the function if i want to stop it when i'm outside the distance of the cloud?


Yeah! IE sucks, use Mozilla...
Marc Rémillard.
Re: sound loop [Re: Marky Mark] #115369
03/06/07 15:49
03/06/07 15:49
Joined: Jul 2002
Posts: 857
Québec
Marky Mark Offline OP
User
Marky Mark  Offline OP
User

Joined: Jul 2002
Posts: 857
Québec
also, my rain sound won't stop ... i dont know why.. maybe the distance scan is not doing his job?


Yeah! IE sucks, use Mozilla...
Marc Rémillard.
Re: sound loop [Re: Marky Mark] #115370
03/06/07 16:01
03/06/07 16:01
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
I'm leaving in 2 minutes, but when I get home I'll check out your code. The problems something small, I just need to see where. The while() needs to be removed from rainit() though.


xXxGuitar511
- Programmer
Re: sound loop [Re: xXxGuitar511] #115371
03/06/07 16:06
03/06/07 16:06
Joined: Jul 2002
Posts: 857
Québec
Marky Mark Offline OP
User
Marky Mark  Offline OP
User

Joined: Jul 2002
Posts: 857
Québec
check out you pm's


Yeah! IE sucks, use Mozilla...
Marc Rémillard.

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1