TNT Basic Forums > Feedback
A variable equals 1,25,50,75 and 100 in the same time?
< Last Thread     Next Thread >
Thread        Post A Reply

08-24-2002 20:04

Posted by:

Find more posts by Matthew

I used the following code to make TNT play different sounds with a certain time between them.

>int time=0
>while not mouse button
>print time
> if time=1 then play sound(3),50,255,1
> if time=25 then play sound(0),50,255,2
> if time=50 then play sound(4),50,255,3
> if time=75 then play sound(2),50,255,4
> if time=100 then play sound(1),50,255,5

I just discovered the sounds are played at once unless I add a <PRIN TIME> line, that fixes all the problem!! HELP!

08-24-2002 20:05

Posted by:

Find more posts by Matthew

OOps! I posted it in feedback! Sorry, I wanted to post it in bugs.

08-26-2002 09:57

Posted by:

Find more posts by Socrates

Asynch sounds

Aren't sounds played asynchronously in TNT? i.e, your program can carry on executing even when a sound is still playing. In that case, the sounds are not being played at the same time, it's just that it plays the first one, keeps counting and then about a millionth of a second later it plays the next one, and so on.

Put in a delay of some kind into the loop, or better yet, use a real time value such a timer, which tells you time in milliseconds. The problem with timing in a loop as you are doing is that even if it works it will only work with your computer because somebody who has a faster computer will find that the sounds still play too quickly. Using timer means that it will run the saem speed on any machine.

Make a variable called startTime and set it to = timer. Then make a new variable called timePassed (the variable names can be whatever you want obviously).

Ecah time round the loop say timePassed = timer - startTime. Timepassed will now tell you the time since you started playing sounds.

Hope this helps.

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.