I am making a c++ game using Haafs game engine and I want to load my levels from a FMP file that I've made with Mappy tile editor. I have made 3 games using hge but never load a level from a fmp file. Since i am new to game programming I am asking for an example of code to initialize the map so i can figure it out. Thank you in advance.
Here is my code:
#include <hge.h>
#include <hgesprite.h>
#include <hgefont.h>
HGE *hge = 0;
//logo texture and sprites
HTEXTURE logotex;
hgeSprite *logospr;
//load sounds and music
HEFFECT bgmenusnd;
//load fonts
hgeFont *font1;
//game variables
bool hide_mouse = false;
bool windowed = true;
bool started = false;
bool FrameFunc()
{
//play sounds and music
hge->Effect_Play(bgmenusnd);
if(hge->Input_GetKeyState(HGEK_ENTER))
{
started = true;
hge->Effect_Free(bgmenusnd);
}
if(hge->Input_GetKeyState(HGEK_ESCAPE))
{
return true;
}
return false;
}
bool RenderFunc()
{
hge->Gfx_BeginScene();
hge->Gfx_Clear(0);
//render logo
if(!started)
logospr->Render(0,0);
//start button
if(!started)
font1->printf(490,470,HGETEXT_LEFT, "Press ENTER to start");
hge->Gfx_EndScene();
return false;
}
void clean_up()
{
//Delete:
//-logo
delete logospr;
hge->Texture_Free(logotex);
//-music
hge->Effect_Free(bgmenusnd);
//-font
delete font1;
//bye bye
hge->System_Shutdown();
hge->Release();
}
int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int)
{
hge = hgeCreate(HGE_VERSION);
hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
hge->System_SetState(HGE_HIDEMOUSE, hide_mouse);
hge->System_SetState(HGE_WINDOWED, windowed);
hge->System_SetState(HGE_DONTSUSPEND, true);
hge->System_SetState(HGE_TITLE, "Itsirinus");
if(hge->System_Initiate())
{
//load logo
logotex = hge->Texture_Load("Images/logo.jpg");
logospr = new hgeSprite(logotex,0,0,1280,1024);
//load sounds
bgmenusnd = hge->Effect_Load("Music/bgmenusnd.mp3");
//load fonts
font1 = new hgeFont("Fonts/font1.fnt");
//start the game
hge->System_Start();
}
//cleaning
clean_up();
return 0;
}