Ok, this is a bit spagged but it works. It loads your logo scene then fades to a title scene where you progress to the game scene by clicking left mouse or space. Escape sends you back to the title screen.
// Project: Template
// Created: 19-04-12
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle("Template")
SetWindowSize(1024, 768, 0)
SetWindowAllowResize(1) // allow the user to resize the window
// set display properties
SetVirtualResolution(1024, 768) // doesn't have to match the window
SetOrientationAllowed(1, 1, 1, 1) // allow both portrait and landscape on mobile devices
SetSyncRate(60, 0) // 30fps instead of 60 to save battery
SetScissor(0, 0, 0, 0) // use the maximum available screen space, no black borders
UseNewDefaultFonts(1)
#insert "constants.agc"
#insert "klogo.scene"
#insert "title.scene"
#insert "game.scene"
global state as string = "logo"
global LogoLoaded as integer = 0
global LogoAlpha as float = 0
global TitleLoaded as integer = 0
global TitleAlpha as float = 0
global GameLoaded as integer = 0
global GameAlpha as float = 0
global GameOut as integer = 0
do
select state
case "logo"
if LogoLoaded = 0
klogo_setup()
LogoLoaded = 1
endif
if LogoLoaded = 1
LogoAlpha = LogoAlpha + 1
klogo_fade(LogoAlpha)
if LogoAlpha > 100
LogoLoaded = 2
endif
endif
if LogoLoaded = 2
LogoAlpha = LogoAlpha - 1
klogo_fade(LogoAlpha)
if LogoAlpha < 0
state = "title"
endif
endif
klogo_sync()
endcase
case "title"
if TitleLoaded = 0
klogo_cleanup()
title_setup()
TitleLoaded = 1
endif
if TitleLoaded = 1
if GameOut = 1
game_cleanup()
GameOut = 0
endif
TitleAlpha = TitleAlpha + 1
title_fade(TitleAlpha)
if TitleAlpha > 100
TitleLoaded = 2
endif
endif
if TitleLoaded = 2
if GetRawKeyPressed(KEY_ESCAPE)
end
endif
if GetRawMouseLeftState() = 1 or GetRawKeyPressed(KEY_SPACE)
TitleLoaded = 3
endif
//Do Title Stuff Here
endif
if TitleLoaded = 3
TitleAlpha = TitleAlpha - 1
title_fade(TitleAlpha)
if TitleAlpha < 0
GameAlpha = 0
GameLoaded = 0
state = "game"
endif
endif
title_sync()
endcase
case "game"
if GameLoaded = 0
title_cleanup()
game_setup()
GameLoaded = 1
endif
if GameLoaded = 1
GameAlpha = GameAlpha + 1
game_fade(GameAlpha)
if GameAlpha > 100
GameLoaded = 2
endif
endif
if GameLoaded = 2
if GetRawKeyPressed(KEY_ESCAPE)
GameLoaded = 3
endif
//DO game stuff here
endif
if GameLoaded = 3
GameAlpha = GameAlpha - 1
game_fade(GameAlpha)
if GameAlpha < 0
GameOut = 1
TitleLoaded = 1
TitleAlpha = 0
endif
endif
if GameOut = 1
state = "title"
endif
game_sync()
endcase
endselect
Print(ScreenFPS())
Sync()
loop
Win 10 Pro - AMD RYZEN 7 Octacore 3.8ghz - 32GB DDR4 - RTX 2070 8GB