As TZ said but without the first part. There is no need to take a snapshot of your screen first, you could still have your game playing while it is fading to black.
If there are no sprites on screen then use a plain make it black, completely transparent, have it fill the screen, disable its zdepth and lock it to the screen. Now bring it's opacity up to max at whatever speed you like.
If there are sprites on screen then you will need to use a sprite instead because the plain won't cover them.
Here is a quick test:
Press SpaceBar to fade to black
Press ReturnKey to fade from black
`Project : Fade Screen
`=========================
`Author : Scraggle
`=========================
`Started : 5th Sept 2006
type T_Cube
x as float
y as float
z as float
xa as float
ya as float
za as float
xs as float
ys as float
zs as float
endtype
dim Cube(50) as T_Cube
Global Alpha as float = 0
Global FadeSpeed as float = 1.0
Global FadeUp as boolean = 0
Global FadeDown as boolean = 0
for k = 1 to 50
make object cube k,rnd(10) + 10
color object k,rnd(16777215)
Cube(k).x = rnd(100)
Cube(k).y = rnd(100)
Cube(k).z = rnd(100)
Cube(k).xs = rnd(100) / 50
Cube(k).ys = rnd(100) / 50
Cube(k).zs = rnd(100) / 50
next k
make object plain 51,640,480
color object 51,0
position object 51,50,50,300
disable object zdepth 51
set alpha mapping on 51 , 0
sync on
sync rate 60
position camera 50,50,-100
point camera 50,50,100
`************************************************************************************
`* *
`* S T A R T O F M A I N L O O P *
`* *
`************************************************************************************
do
GetUserInput()
UpdateWorld()
_DeBug()
sync
loop
`***********************************************************************************
`* *
`* E N D O F M A I N L O O P *
`* *
`***********************************************************************************
`-------------------
` DEBUG
`-------------------
function _DeBug()
text 0,0,"FPS : "+str$(Screen fps())
text 0,10,"Alpha : " +str$(Alpha)
endfunction
`-------------------
` GET USER INPUT
`-------------------
function GetUserInput()
if spacekey() then FadeUp = 1 : FadeDown = 0
if returnkey() then FadeDown = 1 : FadeUp = 0
endfunction
`-------------------
` UPDATE WORLD
`-------------------
function UpdateWorld()
for k = 1 to 50
position object k, Cube(k).x, Cube(k).y, Cube(k).z
inc Cube(k).xa , Cube(k).xs
inc Cube(k).ya , Cube(k).ys
inc Cube(k).za , Cube(k).zs
rotate object k, Cube(k).xa, Cube(k).ya, Cube(k).za
next k
if FadeUp
inc Alpha , FadeSpeed
if Alpha > 99
Alpha = 99
FadeUp = 0
endif
set Alpha mapping on 51, Alpha
endif
if FadeDown
dec Alpha , FadeSpeed
if Alpha < 0
Alpha = 0
FadeDown = 0
endif
set Alpha mapping on 51, Alpha
endif
endfunction