--Description--
You ever wonder how the other game developers display their logo before it fades away looking all cool?
WELL NO MORE!
Hey this is just a simple way to handle displaying and switching between splash screens with a cool fading effect. The code is heavily commented so you shouldn't have to many questions to ask on here.
--Pictures--
None really...
--CODE--
//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
global sw
global sh
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
maximize window
sync
sync rate 60
autocam off
disable escapekey
//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
SplashScreen("Data/Splash_1.png",3000)
SplashScreen("Data/Splash_2.png",3000)
SplashScreen("Data/Splash_3.png",3000)
end
do
sync
LOOP
//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
sync
NEXT 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
sync
NEXT c
delete sprite Splash_SPR
ENDFUNCTION
--Requirements--
Matrix1Utils by IanM
--> Link http://forum.thegamecreators.com/?m=forum_view&t=85209&b=18&msg=954798#m954798 I could've easily done this without using Matrix1Utils but I decided to include it in hopes that it will make more people download it and use it's many amazing features.
AMD FX 6300 hex-core processor 3.5 GHZ
16 GB DDR3 ram, Geforce 660 Ti 2GB ram