rendered paste body/*
** Haaf's Game Engine 1.7
** Copyright (C) 2003-2007, Relish Games
** hge.relishgames.com
*/
#include "hge\hge.h"
#include <list>
HGE *hge=0;
hgeQuad quad;
class Object {
public:
float x; float y; float z;
float width; float height;
char* texture;
};
typedef std::list<Object> Render_list;
Render_list queue;
bool FrameFunc()
{
if (hge->Input_GetKeyState(HGEK_ESCAPE)) return true;
if (hge->Input_GetKeyState(HGEK_LEFT)) return false;
if (hge->Input_GetKeyState(HGEK_RIGHT)) return false;
if (hge->Input_GetKeyState(HGEK_UP)) return false;
if (hge->Input_GetKeyState(HGEK_DOWN)) return false;
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);
for (Render_list::iterator os =queue.begin();
os!=queue.end();
os++) {
quad.blend=BLEND_ALPHAADD | BLEND_COLORMUL | BLEND_ZWRITE;
for(int i=0;i<4;i++)
{
quad.v[i].z=0.5f;
quad.v[i].col=0xFFFFA000;
}
quad.v[0].tx=96.0/128.0; quad.v[0].ty=64.0/128.0;
quad.v[1].tx=128.0/128.0; quad.v[1].ty=64.0/128.0;
quad.v[2].tx=128.0/128.0; quad.v[2].ty=96.0/128.0;
quad.v[3].tx=96.0/128.0; quad.v[3].ty=96.0/128.0;
//(*os) -- reference to objects that are to be rendered.
quad.v[0].x=(*os).x-(*os).width; quad.v[0].y=(*os).y-(*os).height;
quad.v[1].x=(*os).x+(*os).width; quad.v[1].y=(*os).y-(*os).height;
quad.v[2].x=(*os).x+(*os).width; quad.v[2].y=(*os).y+(*os).height;
quad.v[3].x=(*os).x-(*os).width; quad.v[3].y=(*os).y+(*os).height;
hge->Gfx_RenderQuad(&quad);
// spr->SetZ((*os).z);
// spr->Render((*os).x,(*os).y);
}
// 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())
{
Object a;
Object b;
a.x = 100; a.y = 100; a.z = 1;
b.x = 200; b.y = 200; b.z = 1;
a.width = 10; b.width = 10;
a.height = 20; b.height = 10;
quad.tex=hge->Texture_Load("images/particles.png");
// 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;
}