Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. #include "kosSyst.h"
  2. #include "kosFile.h"
  3. #include "gfxdef.h"
  4. #include "mainWnd.h"
  5. #include "gameWnd.h"
  6. #include "top10wnd.h"
  7.  
  8.  
  9.  
  10.  
  11. void kos_Main()
  12. {
  13.         int hdrNum, i;
  14.         SCompBmpHeader *hdrList;
  15.         char *cPtr;
  16.  
  17.         // îòäåëÿåì èìÿ ìîäóëÿ îò ïóòè
  18.         cPtr = strrchr( kosExePath, '/' );
  19.         // ïðîâåðêà ;)
  20. /*      if ( cPtr == NULL )
  21.         {
  22.                 //
  23.                 rtlDebugOutString( "Invalid path to executable." );
  24.                 //
  25.                 return;
  26.         }*/
  27.         //
  28.         cPtr[1] = 0;
  29.         //
  30.         strcpy( top10FilePath, kosExePath );
  31.         //
  32.         strcpy( top10FilePath + ((cPtr - kosExePath) + 1), "fara.t10" );
  33.         //
  34.         PrepareTop10();
  35.         // ïðèêðóòèì èìÿ ôàéëà ñ ãðàôèêîé
  36.         strcpy( cPtr + 1, "fara.gfx" );
  37.         // çàãðóæàåì êàðòèíêè èç ôàéëà
  38.         CKosFile gfxRes( kosExePath );
  39.  
  40.         // ÷èòàåì êîëè÷åñòâî êàðòèíîê â ôàéëå
  41.         if ( gfxRes.Read( (Byte *)&hdrNum, sizeof(hdrNum) ) != sizeof(hdrNum) ) return;
  42.         // ìåñòî ïîä çàãîëîâêè
  43.         hdrList = new SCompBmpHeader[hdrNum];
  44.         // ñ÷èòûâàåì çàãîëîâêè êàðòèíîê
  45.         gfxRes.Read( (Byte *)hdrList, sizeof(SCompBmpHeader) * hdrNum );
  46.         // ðàñïàêîâûâàåì êàðòèíêè
  47.         mainWndFace.LoadFromArch( &(hdrList[MAIN_FACE_NDX]), &gfxRes, MAIN_FACE_NDX );
  48.         gameFace.LoadFromArch( &(hdrList[GAME_FACE_NDX]), &gfxRes, GAME_FACE_NDX );
  49.         gameBlocks.LoadFromArch( &(hdrList[BUTTONS_NDX]), &gfxRes, BUTTONS_NDX );
  50.         gameNumbers.LoadFromArch( &(hdrList[NUMBERS_NDX]), &gfxRes, NUMBERS_NDX );
  51.         // ìàñøòàáèðóåì èåðîãëèôû ê ìåíüøèì ðàçìåðàì
  52.         for ( i = 0; i < 4; i++ )
  53.                 gameBlocksZ[i].Scale(32-i*8,gameBlocks.GetBits());
  54.         //
  55.         delete hdrList;
  56.         // èíèöèàëèçèðóåì áëîêè
  57.         for ( i = 0; i < blocksNum; i++ )
  58.         {
  59.                 //
  60.                 fishki[i] = new CFishka( &gameBlocks, i * blockSize, RGB(0x0) );
  61.         }
  62.         //
  63.         maxGameLevel = START_LEVEL;
  64.         // äîáàâëÿåì ìàñêó äëÿ ñîáûòèé ìûøè
  65.         kos_SetMaskForEvents( 0x27 );
  66.         //
  67.         while ( MainWndLoop() == MW_START_GAME )
  68.         {
  69.                 GameLoop();
  70.                 Top10Loop();
  71.         }
  72.         //
  73.         for ( i = 0; i < blocksNum; i++ )
  74.         {
  75.                 delete fishki[i];
  76.         }
  77.         //
  78.         delete hdrList;
  79. }
  80.  
  81.