-- Main game loop
function Main()

	-- This is technically not needed at the start of main, but it's included
	-- here to remind Playground users to call it before they call Load() again,
	-- so that their progress bar will work correctly.
	LoaderReset();

	DisplaySplash(
		"",
		"splash/bfg_logo",
		4000
		);

	DisplaySplash(
		"",
		"splash/aw_logo",
		4000
		);

	-- Queue up some assets to load
	Load("scripts/preload.loader.lua","coreassets");
	-- Load("scripts/preload.loader.lua","mainmenu");

	-- Bring up the loading screen the first time. The script
	-- will pause here until the loader is done.
	DoModal("scripts/firstload.lua");
--[[
	if (IsFullScreen() == true) then
		ToggleFullScreen();
		ToggleFullScreen();
	end
	--]]
	-- Push the game selection screen
	while true do
		DoMainWindow("scripts/mainmenu.lua");
		-- DoMainWindow will exit only if there are NO windows currently on the stack, so
		-- a PopModal()/PushModal() combination will not cause this to loop.
	end
end

-- Return a function to be executed in a thread
return Main