'Haaf's Game Engine 1.8
'Copyright (C) 2003-2007, Relish Games
'hge.relishgames.com
'**************************************
' FBhge_tut01 - Minimal HGE application
'**************************************
#Include  "inc/HgeType.bi"
#Include  "inc/HgeWrapper.bi"

 'This function will be called by HGE once per frame.
 'Put your game loop code here. In this example we
 'just check whether ESC key has been pressed.

Function  FrameFunc()As  Integer 
 'By returning "true" we tell HGE
 'to stop running the application.
 if (hge_Input_GetKeyState(HGEK_ESCAPE))then return 1
 'Continue execution
 return 0
End Function

   hge_Create(hge_VERSION)
   'Set our frame function
   hge_System_SetStateFunc(HGE_FRAMEFUNC, @FrameFunc)
   'Set the window title 
   hge_System_SetStateString(HGE_TITLE, "FreeBasic HGE Tutorial 01 - Minimal HGE application")
   'Run in windowed mode
   'Default window size is 800x600
   hge_System_SetStateBool(HGE_WINDOWED, 1)
   'Don't use BASS for sound
   hge_System_SetStateInt(HGE_USESOUND,0)
   'Tries to initiate HGE with the states set.
   'If something goes wrong, 0 is returned
   'and more specific description of what have
   'happened can be read with hge_System_GetErrorMessage.
   If (hge_System_Initiate())Then
   'Starts running FrameFunc().
   'Note that the execution "stops" here
   'until 1 is returned from FrameFunc().
      hge_System_Start()
   Else
   'If HGE initialization failed show error message
     MessageBox(NULL, "hge_System_GetErrorMessage", "Error", MB_OK Or MB_ICONERROR Or MB_APPLMODAL)
   End  If  
   'Now ESC has been pressed or the user
   'has closed the window by other means.
   'Restore video mode and free
   'allocated resources
   hge_System_Shutdown()
   'Release the HGE interface.
   'If there are no more references,
   'the HGE object will be deleted.
	hge_Release()