Computer Science Canada

Bubbles???

Author:  Hackster [ Sun Apr 11, 2004 2:29 pm ]
Post subject:  Bubbles???

hey, i was thinking of making a fish screensaver, like where the fish swim around ... and i can't figure out how t make bubbles that go up the screen, and with sound too ... plz, ill post if i get some progress thanks!

Author:  apomb [ Sun Apr 11, 2004 2:46 pm ]
Post subject: 

Well, Well Well i have the perfect thing...
code:

var x, y : int
procedure bubble
    loop
        sound (100, 100)
        sound (200, 50)
        sound (300, 50)
        delay (Rand.Int (500, 2000))
    end loop
end bubble
colorback (blue)
cls
process bubbles
    loop
        x := Rand.Int (1, maxx)
        color (white)
        locatexy (x, 1)
        put "O"
        delay (70)
        color (3)
        locatexy (x, 1)
        put "o"
        delay (70)
        color (3)
        locatexy (x, 1)
        put "."
        delay (70)
    end loop
end bubbles
fork bubbles
bubble

Author:  gamer [ Sun Apr 11, 2004 3:03 pm ]
Post subject: 

hackster, how did u make ur fish program??
plz tell me

Author:  greenapplesodaex [ Sun Apr 11, 2004 3:59 pm ]
Post subject:  reply

i dont get it
there's no saying "y+1" or anything like that, then why does the bubbles go up every loop?
and i know how "fork" works, but i never knew it can generate infinet bubbles this way, can anyone explane???















P.S. pleaaaaaaaaaaaaaaaaaaaase???

Author:  Tony [ Sun Apr 11, 2004 4:39 pm ]
Post subject: 

well after a bit of experimenting, it appears that using locatexy will push the output above up, so there's no need for the y variable Confused
code:

for i:1..10
locatexy(1,1)
put i
end for


the reason for a lot of bubbles is that each time though the loop, a new X value is generated, resulting in a new bubble

Author:  apomb [ Mon Apr 12, 2004 2:16 pm ]
Post subject: 

Yup! this is exactly how i did it, yet i cannot figure out how to make them go DOWN the screen... but ya the next loop just pushes up the last line of text, moving it up the screen. and to explain the "fork" thing, that is the only way i could get the sound to work at the same time as the text moving, otherwise, the bubbles would stop every time there was a sound generated.

Author:  gamer [ Mon Apr 12, 2004 2:45 pm ]
Post subject: 

but the bad thing is that the sound dun even match with each bubble appearing, any way to fix this?

btw if the background is moving water or with moving fishes that'll be MUCH better

Author:  apomb [ Mon Apr 12, 2004 2:53 pm ]
Post subject: 

well, i just wanted the felling of the aquarium, i didn't want to go too in depth with fish and stuff, hackster can do that for himself!

Author:  gamer [ Wed Apr 14, 2004 5:11 pm ]
Post subject: 

ok then 4get the fish, but is it possible to hav the sound played only when a bubble appears?? cuz rite then the sound n bubbles dont match at all

Author:  apomb [ Thu Apr 15, 2004 12:35 pm ]
Post subject: 

there might be, but right now, they are separate processes, like i said before, if they were to run in one process, the bubble would stop while the sound was playing. but i challenge you to try it! Smile


: