It's time to add sound system to my RPG-project..
So, I checked this forum area and I decided that probably that OpenAL would be nice. Thought, now I got new problem:
There's very interesting system with those lakes I have added to the game: they are square areas with few (30-50 etc.) waterparticles. Particles just flies in that area randomly: every time they hit the lake's "wall", it bounces. And that's good place to play "water sound" :twisted: <- playing the sound won't happen always, just randomly..
.....^-> though that bounce-and-play-sound- system won't work now since particles now moves way too slow for that because of that randomizing..
But, the problem itself: I got OpenAL working etc. now in the game, and there are Playsound- methods etc. So, it should just work with sounds.play(waterparticle.sound); but it won't work: the sound just bursts some ear-killing sounds, you know.. so the original sound wont hear :P
Well, I thinked that probably it's true that one sound can play only once at time; if it's playing arleady and you try to play it, it stops, and restarts.. but no. I made little testprogram which plays this same sound every time I click the form; it played smoothly and well; many times at once, producing nice "I'm at lake"- feeling.. :D
But.. why it won't then work in the game..?
Little sample code.. (uhh, I never like to show my codes in public :( )
Code:
{
xs is vertical speed and ys is horizontical..
pq is quantity of lake particles and g[] is array of particles
}
for i := 0 to pq do begin
if random(25)=0 then begin
g[i].x := g[i].x + g[i].xs;
g[i].y := g[i].y + g[i].ys;
if g[i].x > self.lp.x-16 then begin g[i].xs := -g[i].xs; e:=true; end;
if g[i].x <self> self.lp.y-16 then begin g[i].ys := -g[i].ys; e:=true; end;
if g[i].y < self.ap.y+16 then begin g[i].ys := -g[i].ys; e:=true; end;
end;
if random(500)=0 then sounds.find(g[i].sound).play;
can.Draw(Asphyreimage.Image[g[i].grf], extrax+g[i].x, extray+g[i].y, 0, fxBlend);
end;
I already tried to add each g[] their own sound.. same result :/ didn't helpo. And ate lot of memory ;D
..by the way.. is it very dump to use random() function like that? It reduces usage of CPU and makes lakes look a bit more slow, like in nature.. :D I'm using very peculiar methods in this game though :)
Ahh.. what an messy message.. sorry for that. Hope someone gots it. I'm a bit tired right now, and head full of stuff :)
Bookmarks