X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=ABM2%2Fmain.cpp;h=e325647b86402a4ca002bcbea96218abba118c16;hb=887e744e425c6c25fcfdbad863d3c9287ad91d93;hp=061cce287b80b62b7731f51d5ac2c27f1b077c21;hpb=0b314338a46fe83c1c4bb646da858ebd5d4a7317;p=matthijs%2FABM2.git diff --git a/ABM2/main.cpp b/ABM2/main.cpp index 061cce2..e325647 100755 --- a/ABM2/main.cpp +++ b/ABM2/main.cpp @@ -1,9 +1,12 @@ // include the basic windows header files and the Direct3D header file +#ifdef WIN32 #include #include +#endif #include "Engine/engine.h" #include "Engine/game.h" +#include "Engine/SpriteManager.h" #include "Playground.h" #include "SchemeReader.h" @@ -11,13 +14,28 @@ #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 480 +enum SpriteID { + SPR_NONE = 0, + SPR_FIELD, + SPR_SOLID, + SPR_BRICK, + SPR_BLANK, + SPR_PLAYER, +}; + +SpriteData defaultSprites[] = { + {SPR_FIELD, "FIELD0.png", 640, 480}, + {SPR_BLANK, "FIELD0.png", 640, 480}, + {SPR_NONE, NULL, 0, 0} +}; + +#ifdef WIN32 HINSTANCE hInstance; HWND hWnd; // the WindowProc function prototype LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); - class CPongTask : public ITask { public: @@ -118,6 +136,7 @@ public: AUTO_SIZE; }; +#endif // WIN32 void CApplication::Run(int argc, char *argv[]) { //open logfiles @@ -152,6 +171,9 @@ void CApplication::Run(int argc, char *argv[]) globalTimer->priority=10; CKernel::GetSingleton().AddTask(CMMPointer(globalTimer)); + CSpriteManager *sm = new CSpriteManager(videoTask->getGraphics(), defaultSprites); + CKernel::GetSingleton().setSpriteManager(sm); + Playground game; game.priority=100; CKernel::GetSingleton().AddTask(CMMPointer(&game)); @@ -168,6 +190,7 @@ void CApplication::Run(int argc, char *argv[]) delete CSettingsManager::GetSingletonPtr(); } +#ifdef WIN32 // the entry point for any Windows program int WINAPI WinMain(HINSTANCE hInst, @@ -215,7 +238,6 @@ int WINAPI WinMain(HINSTANCE hInst, return 0; } - // this is the main message handler for the program LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { @@ -230,3 +252,17 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara return DefWindowProc (hWnd, message, wParam, lParam); } +#else // WIN32 +int main(int argc, char *argv[]) +{ + new CApplication(); + CApplication::GetSingleton().Run(argc,argv); + delete CApplication::GetSingletonPtr(); + + //clean up any remaining unreleased objects + IMMObject::CollectRemainingObjects(true); + + return 0; +} +#endif //WIN32 +