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.
//SPLASH SCREEN DEMO
//Hopefully by the end of this demo you will understand how to create a splashscreen
//for your games and other programs. I will do my best to comment the code and try
//to explain what's going on.
//Setup the main window (Inspired from Evolved's lighting files)
Load dll "user32.dll",1
// The two lines below this get the width and height of the users screen
sw = call dll (1,"GetSystemMetrics",0) //<--- Width
sh = call dll (1,"GetSystemMetrics",1) //<--- Height
delete dll 1
set display mode sw,sh,32,1 //Apply the width and height to the window along with the depth
set window title "Splash Screen Demo" //Give it a nice little title to let the user know what's up
sync rate 60
//You would call the splashscreen function(s) outside of the main loop because they contain loops
//within themselves. After displaying your splashscreens you would have the program jump to your
//menu or next gamestate
//This is the function for the splash screen
function SplashScreen(File$,Time#) //<--- The function itself. The variables "File$" is used to load an image to display for your splashscreen and "Time#" is to set how long to display it.
Splash_IMG = find free image() //<--- This variable is the image number
Splash_SPR = find free sprite() //<--- This variable is the sprite number
load image File$,Splash_IMG //<--- Remember what I said about the "File$" string? This is where you load it and give the the image number we talked about earlier.
sprite Splash_SPR,0,0,Splash_IMG //This creates the sprite that is your splashscreen using the Splash_IMG and Splash_SPR varibles we declared earlier
size sprite Splash_SPR,sw,sh //This line simply scales the sprite to the size of the window
paste sprite Splash_SPR,0,0
//Fade in effect
//Here is where things might look confusing but they're REALLY simple.
//this simply makes the sprite go from using no color at all to using full color
//we use a for loop because once it hits it's target value it ends which is what we need for this
//The "f" in the code is the number we're using for the RGB color values.
//The "255" is the max level we want "f" to be able to reach
//and step is what we use to determine by what increments it goes from 0 to 255
for f=0 to 255 step 5
set sprite diffuse Splash_SPR,f,f,f
wait Time# //<--- This line is the variable that you declare when using the function. It determines how long the splashscreen should display for in milliseconds
//Fade Out effect
//More or less what you learned above but now you want it to go from using full color to black
for c=255 to 0 step -5
set sprite diffuse Splash_SPR,c,c,c
delete sprite Splash_SPR
Login to post a reply