Let me insert myself here and dispel a few mysteries..
The vignette is a darkening of the edges of the screen.
You can see a great example of it in action in the level EXTREME PWN LAZ0RZ!! http://www.dyson-game.com/smf/index.php?topic=1222.0
During the opening of this level, there is a heavy vignette around the edges (you can notice it if you look for it) which keeps the visual focus on the centre of the screen. After a few moments, the vignette starts to fade, creating the feeling of the level "opening up"; then the player gains control of the mine and the level begins.
I suspect from your description that the vignette is not what you really want. I think you probably want the entire screen to fade in and out, rather than just the edges.
If that's the case, I guess the way I would suggest to do it is to have a very large sprite that fills the screen. It would be 100% opaque when the level loads, then becomes gradually more and more transparent until it's 100% transparent, then you're done.
Hopefully this would hide any asteroids/seedlings behind it.
That's the way I'd tackle this problem, anyway. I'd be interested to hear how you get on with this. :>
Also,
-- set backdrop and vignette
bw = math.random(0,1)
This creates a variable called "bw" and sets it to either 0, or 1.
This will be used to decide whether the level will have a black background, or white background - and which set of star effects will be used.
SetBackdropColour(bw*210,bw*227,bw*224)
Sets the backdrop colour.
At this point, bw is either 0 or 1. If it's 0, the colour ends up being 0,0,0 which is black. If it's 1, the colour ends up being 210,227,224 which is very light grey.
SetVignetteAlpha(0)
Sets the vignette alpha to be 100% opaque. The "alpha" is how transparent it is; 0 means opaque, 255 means transparent.
if bw == 1 then
Did we select 1 for bw? (as opposed to 0)
SetVignetteAlpha(255)
Assuming bw == 1, we now proceed to set the Vignette to 100% opaque.
bw = 255
end
The bw variable is recycled at this point to be used for the vignette fade...
Then we get to the next section:
if GetGameTime() < 10 then
For the first 10 seconds of game time, do the following:
Globals.Structures.RootSpeed=15
Set the root speed... I think this was so the player can watch the roots travelling to the centre of the asteroid more slowly during the intro.
if GetGameTime() > 1 then
If more than 1 second has passed (and, logically, less than 10 seconds, as per above)
if bw > 50 then
Check if the bw value (which we set to 255 earlier) is more than 50.
bw = bw - 1
Assuming it was more than 50, reduce the value of bw by 1.
SetVignetteAlpha(bw)
end
end
Now set the vignette to the value of bw.
bw is going to count down from 255 until it reaches 51, then the vignette will stay at that value.
The game processes a while GameRunning() loop 60 times per second, so we can calculate that it will take a little over 3 seconds for the transition to complete.
IE, 255 - 51 = 204. 204/60 = 3.4
Hope that explains it. The example you've chosen is heavily convoluted by all the extra stuff I wanted to do; a very simple vignette fader would be something like this:
--To be placed inside LevelSetup
-- set vignette alpha
-- starts on 255 (fully opaque)
vig=255
-- set the initial vignette
SetVignetteAlpha(vig)
--To be placed inside a While GameRunning() loop inside LevelLogic
-- set vignette alpha
-- if the fade is not yet complete...
if vig > 0 then
-- fade out one more step..
vig = vig - 1
-- set the vignette to the value of vig
SetVignetteAlpha(vig)
end
That will cause the vignette to be there when the level loads, but to fade out, disappearing completely at 0:04:25 game time (ie after 4 and a bit seconds).
As per above though, I suspect this is not really the effect you want..