Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / for next loop bug

Author
Message
Graysire
11
Years of Service
User Offline
Joined: 18th Oct 2013
Location:
Posted: 18th Oct 2013 21:21
for music = 1 to 100
play sound rnd(7)+50
if sound playing (50)then wait 172000
if sound playing (51)then wait 168000
if sound playing (52) then wait 69000
if sound playing (53) then wait 46000
if sound playing (54) then wait 118000
if sound playing (55) then wait 255000
if sound playing (56) then wait 74000
if sound playing (57) then wait 235000
next music
this is right below the sound loading. the wait is the length of the sound in miliseconds. for some reason it takes awhile to load
and plays all at once. help?
Kingius Returns
11
Years of Service
User Offline
Joined: 17th Oct 2013
Location: UK
Posted: 18th Oct 2013 22:56
I wonder if sound playing is getting false immediately after your play sound. If so that would then cause the loop to trigger without any of the waits happening. Perhaps try putting a sync in between the play sound and the sound playing checks to force DB to update, see if that helps.
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 19th Oct 2013 03:10
What is it you're trying to do? Because there is probably a better way of writing your code.

Mobiius
Valued Member
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 19th Oct 2013 04:08
Why not do this:



Graysire
11
Years of Service
User Offline
Joined: 18th Oct 2013
Location:
Posted: 21st Oct 2013 20:04
Thanks for the help. but for some reason it broke this later in the code. do
REM SCREEN DISPLAY
REM CONTROL INPUT
if Keystate(scancode())=1 then gosub OptionsSection
REM REFRESH SCREEN
sync
loop.

i don't understand why doing this with sound breaks the title screen
Derek Darkly
13
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 22nd Oct 2013 17:12
You should explain more clearly what you're going for.

Are you trying to keep a title screen up while certain sounds play?

D.D.
Graysire
11
Years of Service
User Offline
Joined: 18th Oct 2013
Location:
Posted: 22nd Oct 2013 19:54
i am sorry for confusion. allow me to be perfectly clear.
For MLoop = 1 to 100
MFile = Rnd ( 7 ) + 50
Play Sound MFile
Repeat
Sync
Until Sound Playing( MFile ) = 0
Next MLoop
REM SCREEN DISPLAY
REM CONTROL INPUT
if Keystate(scancode())=1 then gosub OptionsSection
REM REFRESH SCREEN
sync
loop.
that is the code.
it plays the music and for some reason the keystate(hit any key to start) does not work. or it takes a huge amount of loading.
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 23rd Oct 2013 09:02 Edited at: 23rd Oct 2013 09:03
Yeah that will be very slow. Since the repeat section of the code makes it wait until that music/sound or whatever your trying to load plays through until the end before proceeding.

This,




If you want the user to be able to interact while the music is playing you'll need to build a loop that manages the music and checks for input .

(Note: pseudo code)



Login to post a reply

Server time is: 2025-05-15 14:04:09
Your offset time is: 2025-05-15 14:04:09