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.

Newcomers DBPro Corner / Better Timing for Fades

Author
Message
Rknight
20
Years of Service
User Offline
Joined: 25th Sep 2003
Location: NJ
Posted: 6th Jun 2004 23:55
Here's a simple fade in/fade out routine for images. It goes by instantly so you can't see it, unless you insert a 'WAIT' command in there.

The problem for me is the slowest the wait command will go 'WAIT 1' (I've tried WAIT .01 seems to make no difference' is too slow, the fade in/out is not fast enough.

How can I precisely time the fade ins/out, so that it's against a clock and the same on different speed machines (barring a really low caliber video card or some such other problem)?

I've been experimenting with if/then statements and timer() based increments but no luck so far as it seems to slow things down too much. But I might not have just got the right combination of commands.

LOAD IMAGE ONE$,1,1
LOAD IMAGE TWO$,2,1

SPRITE 1,10,10,1
SPRITE 2,10,10,2

FOR X=1 to 255
set sprite alpha 1,255-x
set sprite alpha 2,X
next x
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 7th Jun 2004 00:33
there is no point in fading an image out faster than the monitor can refresh the image, check your settings and for a guess your monitor refreshes 70 or 100 times a second, so if you want the fade to last one second and the refresh is 100 times a second at the monitor then you need to turn on manual syncing and reduce the total fade value by 100th, so if as in your example you fade the image from 1 to 255, then fade by 2.5 per frame and then sync (take two extra frames over to get the remaning 5), if you want to go faster then fade by more per step, you can`t fade any smoother than that since the screen only refreshes 100 times a second, so if you faded (for example) by 300 steps in a second then you would only ever see the 100 frames the monitor actualy drew, the other 200 frames are just a waste of cpu/gpu power since they will never get drawn, hope that explains things ok.

Mentor.

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, Nvidia FX5900 gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster, ups.
Rknight
20
Years of Service
User Offline
Joined: 25th Sep 2003
Location: NJ
Posted: 7th Jun 2004 04:57 Edited at: 7th Jun 2004 04:58
Ah yes. That's helpful. I see what you mean. Thanks.

I wish I didn't have to use the SYNC command, I'd prefer to be able to set a time variable and use some variation on WAIT, but it looks like the way to go.

Login to post a reply

Server time is: 2024-09-22 12:44:47
Your offset time is: 2024-09-22 12:44:47