/*
** Haaf's Game Engine 1.7
** Copyright (C) 2003-2007, Relish Games
** hge.relishgames.com
**
** hge_tut02 - Using input, sound and rendering
*/
#include "..\..\include\hge.h"
HGE *hge=0;
bool FrameFunc()
{
if (hge->Input_GetKeyState(HGEK_ESCAPE)) return true;
if (hge->Input_GetKeyState(HGEK_LEFT))
if (hge->Input_GetKeyState(HGEK_RIGHT))
if (hge->Input_GetKeyState(HGEK_UP))
if (hge->Input_GetKeyState(HGEK_DOWN))
return false;
}
// This function will be called by HGE when
// the application window should be redrawn.
// Put your rendering code here.
bool RenderFunc()
{
// Begin rendering quads.
// This function must be called
// before any actual rendering.
hge->Gfx_BeginScene();
// Clear screen with black color
hge->Gfx_Clear(0);
// End rendering and update the screen
hge->Gfx_EndScene();
// RenderFunc should always return false
return false;
}
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
// Get HGE interface
hge = hgeCreate(HGE_VERSION);
// Set up log file, frame function, render function and window title
hge->System_SetState(HGE_LOGFILE, "hge_tut02.log");
hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
hge->System_SetState(HGE_TITLE, "Game title");
// Set up video mode
hge->System_SetState(HGE_WINDOWED, true);
hge->System_SetState(HGE_SCREENWIDTH, 800);
hge->System_SetState(HGE_SCREENHEIGHT, 600);
hge->System_SetState(HGE_SCREENBPP, 32);
if(hge->System_Initiate())
{
// Let's rock now!
hge->System_Start();
}
else MessageBox(NULL, hge->System_GetErrorMessage(), "Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL);
// Clean up and shutdown
hge->System_Shutdown();
hge->Release();
return 0;
}