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 / Pressing question on timing and syncronisation

Author
Message
Terabyte
23
Years of Service
User Offline
Joined: 28th Dec 2002
Location: UK
Posted: 28th Sep 2003 23:41
I keep forgetting to ask this.
Lets say i want to make an image fade in and fade out, or maybe even the contents of the screen. You can do this by sprite alpha or by screen gamma

For ages ive been doing it like this:

for t=0 to 255
set gamma t,t,t
next t
for t=255 to 0 step -1
set gamma t,t,t
next t

or ive done it

do
t=t+1
set gamma t,t,t
if t=255 then exit
loop
do
t=t-1
set gamma t,t,t
if t=0 then exit
loop

Due to the speed of my graphics card i seem to always get the speed i want with these on their own
somtimes though, I spend ages putting sleeps in between and trying to get the rate at which it fades in and out just right.

And then i go and play it on a mates pc

And im either sitting there for ages waiting for the screen to go. or im watching the entire credits and start sequence of the game woosh through and left thinking WTF

whats the "specimine" way of getting a screen to fade in and out at a rate that all pc's will go at.

Some pc's just rish through the loop and others just ... take for ever. is there a way of getting everything together.. somehow i think this is another topic all about sync! oh well..

>>TerraByte. Putting the Byte back into Terragramming<< Life is like a sheet sandwich you take a bigger piece everyday.
Wik
23
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 28th Sep 2003 23:43
I think you can use the timer() command

The rock has rolled!
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 28th Sep 2003 23:51
First thing is that you need a SYNC command in your loop. Then you can do one of two things.

You can use the timer() for exact split second accuracy, or you can set the SYNC rate to something like 30 FPS, do your fade, then change it back to whatever you want the rest of the game to run at. So long as you choose a low FPS, all computers should look similar.

BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php
Terabyte
23
Years of Service
User Offline
Joined: 28th Dec 2002
Location: UK
Posted: 28th Sep 2003 23:57
very nice...

hows aboot some code eh?

>>TerraByte. Putting the Byte back into Terragramming<< Life is like a sheet sandwich you take a bigger piece everyday.
Benjamina
22
Years of Service
User Offline
Joined: 7th Sep 2003
Location:
Posted: 29th Sep 2003 03:34
How about using a ghosted plain in front of the camera. This is good if you're in a 3D screen and want to fade to a specific colour.

As for 2D fades you might be able to do this with sprites but I'm not sure. Create an image and then use the image as a transparent sprite and fade it out...if this can be done then it would be good because you could also fade 2D screens that way. The ghosted plain sounds like a really good idea for 3D screens but I would prefer to use 2D screens for menus and so on.

Many good things come in small packages
spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 29th Sep 2003 03:58
Its late and I'm falling asleep so pick what you need out of this!

It's just a bit of code for front of my compo entry where alienware logo fades in taking 1 second, waits 3 seconds, then takes 1 second to fade out.



If your mansion house needs haunting, just call Rentaghost!
Terabyte
23
Years of Service
User Offline
Joined: 28th Dec 2002
Location: UK
Posted: 29th Sep 2003 21:26
@Benjamina the post wasnt how do you fade. the post was how do you fade at a certain speed

ill try that code in a minute spooky

Login to post a reply

Server time is: 2026-07-25 07:02:24
Your offset time is: 2026-07-25 07:02:24