TimeWiseLogic::TimeWiseLogic(void){ _manager = new CommandManager(_taskList); _logger = Logger::getLogger(); _displayType=MAIN; _cmd = NULL; initLogic(); }
WorldRenderer::WorldRenderer(JNIEnv* env, jint _width, jint _height, jobject _pngManager, jobject javaAssetManager) { LOGI("Engine::constructor Engine"); art = new Art(); art->init(env, _width, _height, _pngManager, javaAssetManager); art->setupGraphics(_width, _height); initLogic(); LOGI("Engine::constructor finished"); }
static void init(){ initGL(); initModel(); initLogic(&game); }
int main(int argc, char** argv) { (void) argc; (void) argv; /*srand(time(NULL));*/ #ifdef WIN32 { LARGE_INTEGER divisor; QueryPerformanceFrequency(&divisor); clockDivisor = divisor.QuadPart; } #else clockDivisor = CLOCKS_PER_SEC; #endif printf("Starting\nClock divisor: %lu\n", clockDivisor); struct graphics g = { #ifdef SHOWKEYS .width = 100, .height = 100, #else .width = 1200, .height = 900, #endif }; initiateGraphics(&g, "Test window"); if(!g.window) goto CLEANUP; /*thread t;*/ /*newThread(test, NULL, &t);*/ clockType frameStart, frameEnd, gameStart; getClockTime(&frameStart); initLogic(); loadEntities(); loadTileTextures(); initializeWorld(); initializeBullets(); initializeItems(); initializeItemFunctions(); luaStart(); getClockTime(&gameStart); while(1){ cameraTick(); renderGraphics(&g); oldMouseState = mouseState; mouseState = SDL_GetMouseState(&mouseX, &mouseY); if(oldMouseState != mouseState){ mouseEvent(); } for(SDL_Event event; SDL_PollEvent(&event);){ switch(event.type){ case SDL_QUIT: goto CLEANUP; case SDL_KEYDOWN: case SDL_KEYUP: if(event.key.keysym.scancode == 0x14) goto CLEANUP; //TODO keyEvent(event.key); break; } } getClockTime(&frameEnd); frameTime = getDiffClock(frameStart, frameEnd); appTime = getDiffClock(gameStart, frameEnd); frameStart = frameEnd; gameUpdate(); } CLEANUP: luaEnd(); uninitializeItems(); uninitializeItemFunctions(); uninitializeBullets(); uninitializeWorld(); unloadTileTextures(); unloadEntities(); destroyGraphics(&g); return 0; } float normalRandomFloat(){ return ((float) rand()) / ((float) RAND_MAX); } float randomFloat(float a, float b){ float diff = b - a; return a + normalRandomFloat() * diff; }