1
0
kolibrios/programs/games/fara/trunk/main.cpp
2011-01-30 10:48:08 +00:00

81 lines
1.9 KiB
C++

#include "kosSyst.h"
#include "kosFile.h"
#include "gfxdef.h"
#include "mainWnd.h"
#include "gameWnd.h"
#include "top10wnd.h"
void kos_Main()
{
int hdrNum, i;
SCompBmpHeader *hdrList;
char *cPtr;
// îòäåëÿåì èìÿ ìîäóëÿ îò ïóòè
cPtr = strrchr( kosExePath, '/' );
// ïðîâåðêà ;)
/* if ( cPtr == NULL )
{
//
rtlDebugOutString( "Invalid path to executable." );
//
return;
}*/
//
cPtr[1] = 0;
//
strcpy( top10FilePath, kosExePath );
//
strcpy( top10FilePath + ((cPtr - kosExePath) + 1), "fara.t10" );
//
PrepareTop10();
// ïðèêðóòèì èìÿ ôàéëà ñ ãðàôèêîé
strcpy( cPtr + 1, "fara.gfx" );
// çàãðóæàåì êàðòèíêè èç ôàéëà
CKosFile gfxRes( kosExePath );
// ÷èòàåì êîëè÷åñòâî êàðòèíîê â ôàéëå
if ( gfxRes.Read( (Byte *)&hdrNum, sizeof(hdrNum) ) != sizeof(hdrNum) ) return;
// ìåñòî ïîä çàãîëîâêè
hdrList = new SCompBmpHeader[hdrNum];
// ñ÷èòûâàåì çàãîëîâêè êàðòèíîê
gfxRes.Read( (Byte *)hdrList, sizeof(SCompBmpHeader) * hdrNum );
// ðàñïàêîâûâàåì êàðòèíêè
mainWndFace.LoadFromArch( &(hdrList[MAIN_FACE_NDX]), &gfxRes, MAIN_FACE_NDX );
gameFace.LoadFromArch( &(hdrList[GAME_FACE_NDX]), &gfxRes, GAME_FACE_NDX );
gameBlocks.LoadFromArch( &(hdrList[BUTTONS_NDX]), &gfxRes, BUTTONS_NDX );
gameNumbers.LoadFromArch( &(hdrList[NUMBERS_NDX]), &gfxRes, NUMBERS_NDX );
// ìàñøòàáèðóåì èåðîãëèôû ê ìåíüøèì ðàçìåðàì
for ( i = 0; i < 4; i++ )
gameBlocksZ[i].Scale(32-i*8,gameBlocks.GetBits());
//
delete hdrList;
// èíèöèàëèçèðóåì áëîêè
for ( i = 0; i < blocksNum; i++ )
{
//
fishki[i] = new CFishka( &gameBlocks, i * blockSize, RGB(0x0) );
}
//
maxGameLevel = START_LEVEL;
// äîáàâëÿåì ìàñêó äëÿ ñîáûòèé ìûøè
kos_SetMaskForEvents( 0x27 );
//
while ( MainWndLoop() == MW_START_GAME )
{
GameLoop();
Top10Loop();
}
//
for ( i = 0; i < blocksNum; i++ )
{
delete fishki[i];
}
//
delete hdrList;
}