#include "CRM32Pro.h"
#include "../source/MSTE.h"
#include "../source/MSTE_MapData.h"
#define EXAMPLE_VERSION "MSTE - Example02: Import"
void RenderGraphics(int);
int main(int argc,char *argv[])
{
Uint8 done = 0;
SDL_Event event;
ILogSystem.Init("Example02_Import.log",LOG_FILE,LOG_NORMAL,EXAMPLE_VERSION);
if(CRM32Pro.Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) < 0)
{
ILogSystem.Msg(LOG_NORMAL," [LOG] - Couldn't initialize CRM32Pro: %s\n",SDL_GetError());
return 1;
}
CRM32Pro.Config.Title = EXAMPLE_VERSION;
CRM32Pro.Config.VideoWidth = 640;
CRM32Pro.Config.VideoHeight = 400;
CRM32Pro.Config.bMTFriendly = 1;
if(!CRM32Pro.SetVideoMode())
{
CRM32Pro.Quit();
return 1;
}
ITimeSystem->Init();
ITimeSystem->SetRate(60,20);
CRM32Pro.SetRenderCallback(RenderGraphics);
TE->
Init(2,
"MySecondLevel");
TE->
ImportImage(0,
"import_bg.bmp", 64, 64);
TE->ImportImage(1, "import_fg.png", 32, 32);
int iPause = -1;
int iSmooth = -1;
while(!done)
{
while(CRM32Pro.Update(&event))
{
switch(event.type)
{
case SDL_QUIT:
done = 1;
break;
case SDL_KEYDOWN:
if(event.key.keysym.sym == SDLK_ESCAPE) done = 1;
if(event.key.keysym.sym == SDLK_c)
{
int iCX,iCY;
iCX = iCY = -1;
ILogSystem.Msg(LOG_NORMAL," [Screen2LayerCell(1) => (%d,%d)\n",iCX,iCY);
ILogSystem.Msg(LOG_NORMAL," [Screen2LayerAbsolute(1) => (%d,%d)\n",iCX,iCY);
}
if(event.key.keysym.sym == SDLK_p)
{
iPause = iPause * (-1);
}
if(event.key.keysym.sym == SDLK_s)
{
iSmooth = iSmooth * (-1);
}
default:
break;
}
}
if(CRM32Pro.GetKeystate(SDLK_UP)) TE->
MoveLayer(1,0,-4);
if(CRM32Pro.GetKeystate(SDLK_DOWN)) TE->
MoveLayer(1,0,4);
if(CRM32Pro.GetKeystate(SDLK_LEFT)) TE->
MoveLayer(1,-4,0);
if(CRM32Pro.GetKeystate(SDLK_RIGHT)) TE->
MoveLayer(1,4,0);
}
delete TE;
ITimeSystem->Info();
CRM32Pro.VideoInfo();
return 0;
}
void RenderGraphics(int bLogicUpdate)
{
}