#include "CRM32Pro.h"
#include "../source/MSTE.h"
#include "../source/MSTE_MapData.h"
#define EXAMPLE_VERSION "MSTE - Example01: Init"
CRM32Pro_CTile *tilset;
void ManualLoad();
void RenderGraphics(int);
int main(int argc,char *argv[])
{
Uint8 done = 0;
SDL_Event event;
ILogSystem.Init("Example01_Init.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 = 320;
CRM32Pro.Config.VideoHeight = 240;
CRM32Pro.Config.bMTFriendly = 1;
if(!CRM32Pro.SetVideoMode())
{
CRM32Pro.Quit();
return 1;
}
ITimeSystem->Init();
ITimeSystem->SetRate(60,20);
CRM32Pro.SetRenderCallback(RenderGraphics);
TE->
Init(3,
"MyFirstLevel");
ManualLoad();
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_1)
if(event.key.keysym.sym == SDLK_2)
if(event.key.keysym.sym == SDLK_3)
if(event.key.keysym.sym == SDLK_4)
if(event.key.keysym.sym == SDLK_5)
if(event.key.keysym.sym == SDLK_6)
if(event.key.keysym.sym == SDLK_c)
{
int iCX,iCY;
iCX = iCY = -1;
ILogSystem.Msg(LOG_NORMAL," [Screen2LayerCell(2) => (%d,%d)\n",iCX,iCY);
ILogSystem.Msg(LOG_NORMAL," [Screen2LayerAbsolute(2) => (%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(2,0,-4);
if(CRM32Pro.GetKeystate(SDLK_DOWN)) TE->
MoveLayer(2,0,4);
if(CRM32Pro.GetKeystate(SDLK_LEFT)) TE->
MoveLayer(2,-4,0);
if(CRM32Pro.GetKeystate(SDLK_RIGHT)) TE->
MoveLayer(2,4,0);
}
delete TE;
if(Map0 != NULL) delete Map0;
if(Map1 != NULL) delete Map1;
if(Map2 != NULL) delete Map2;
if(tilset != NULL) delete tilset;
ITimeSystem->Info();
CRM32Pro.VideoInfo();
CRM32Pro.Quit();
return 0;
}
void RenderGraphics(int bLogicUpdate)
{
}
void ManualLoad()
{
tilset = new CRM32Pro_CTile;
if(tilset->Create("tiles.bmp","test"))
{
tilset->SetTileSet(1,48,48);
tilset->SetColorKey(0xFF00FF);
}
else { delete tilset; tilset = NULL; }
if(Map0->
CheckMap() == 0) ILogSystem.Msg(LOG_NORMAL,
" - ManualLoad() has found problems checking the map on layer 0\n");
Map1->
iTilemap[0][3] = 2;
Map1->iTilemap[0][8] = 2;
Map1->iTilemap[1][11] = 2;
Map1->iTilemap[1][15] = 2;
Map1->iTilemap[2][2] = 2;
Map1->iTilemap[3][5] = 2;
Map1->iTilemap[3][8] = 2;
Map1->iTilemap[3][13] = 2;
Map1->iTilemap[4][3] = 2;
Map1->iTilemap[5][9] = 2;
Map1->iTilemap[6][1] = 2;
Map1->iTilemap[6][14] = 2;
Map1->iTilemap[7][4] = 2;
Map1->iTilemap[7][8] = 2;
Map1->iTilemap[8][10] = 2;
Map1->iTilemap[9][3] = 2;
Map1->iTilemap[10][8] = 2;
Map1->iTilemap[10][13] = 2;
Map1->iTilemap[11][1] = 2;
Map1->iTilemap[11][12] = 2;
Map1->iTilemap[12][5] = 2;
Map1->iTilemap[13][8] = 2;
Map1->iTilemap[14][2] = 2;
Map1->iTilemap[14][11] = 2;
Map2->iTilemap[1][4] = 3;
Map2->iTilemap[1][8] = 4;
Map2->iTilemap[2][4] = 3;
Map2->iTilemap[2][5] = 3;
Map2->iTilemap[2][6] = 3;
Map2->iTilemap[2][8] = 4;
Map2->iTilemap[2][11] = 3;
Map2->iTilemap[2][12] = 3;
Map2->iTilemap[2][13] = 3;
Map2->iTilemap[3][1] = 4;
Map2->iTilemap[3][2] = 4;
Map2->iTilemap[3][3] = 4;
Map2->iTilemap[3][5] = 3;
Map2->iTilemap[3][6] = 3;
Map2->iTilemap[3][12] = 3;
Map2->iTilemap[3][13] = 3;
Map2->iTilemap[4][8] = 3;
Map2->iTilemap[4][9] = 3;
Map2->iTilemap[4][10] = 3;
Map2->iTilemap[5][4] = 3;
Map2->iTilemap[5][5] = 3;
Map2->iTilemap[5][6] = 3;
Map2->iTilemap[5][8] = 3;
Map2->iTilemap[5][10] = 3;
Map2->iTilemap[5][13] = 4;
Map2->iTilemap[5][14] = 4;
Map2->iTilemap[6][4] = 3;
Map2->iTilemap[6][6] = 3;
Map2->iTilemap[6][8] = 3;
Map2->iTilemap[6][9] = 3;
Map2->iTilemap[6][10] = 3;
Map2->iTilemap[7][4] = 3;
Map2->iTilemap[7][5] = 3;
Map2->iTilemap[7][6] = 3;
Map2->iTilemap[7][13] = 3;
Map2->iTilemap[7][14] = 3;
Map2->iTilemap[8][9] = 4;
Map2->iTilemap[8][10] = 4;
Map2->iTilemap[8][11] = 4;
Map2->iTilemap[9][3] = 3;
Map2->iTilemap[9][4] = 3;
Map2->iTilemap[9][6] = 3;
Map2->iTilemap[9][7] = 4;
Map2->iTilemap[9][9] = 4;
Map2->iTilemap[9][10] = 3;
Map2->iTilemap[9][11] = 4;
Map2->iTilemap[9][14] = 3;
Map2->iTilemap[10][3] = 3;
Map2->iTilemap[10][4] = 3;
Map2->iTilemap[10][6] = 4;
Map2->iTilemap[10][7] = 3;
Map2->iTilemap[10][9] = 4;
Map2->iTilemap[10][10] = 4;
Map2->iTilemap[10][11] = 4;
Map2->iTilemap[10][14] = 3;
Map2->iTilemap[11][13] = 3;
Map2->iTilemap[11][14] = 3;
Map2->iTilemap[12][2] = 4;
Map2->iTilemap[12][5] = 3;
Map2->iTilemap[12][6] = 3;
Map2->iTilemap[12][8] = 4;
Map2->iTilemap[12][9] = 4;
Map2->iTilemap[13][5] = 3;
Map2->iTilemap[13][6] = 3;
Map2->iTilemap[13][7] = 3;
Map2->iTilemap[13][10] = 3;
Map2->iTilemap[13][13] = 4;
Map2->iTilemap[14][3] = 4;
Map2->iTilemap[14][9] = 4;
Map2->iTilemap[14][13] = 4;
}