#include #include #include #include #include #include #include #include "config.h" #include "types.h" #include "game.h" #include "map.h" #include "draw.h" #include "ui.h" #include "lua_inter.h" // Idées : // - Drogues /* TODO * UI worker/machine : * map : * - Textures : x * - Génération : */ #if DEBUG FILE *log_file; char *log_levels[] = { "???", "TRACE", "DEBUG", "INFO", "WARNING", "ERROR", "FATAL", "!!!" }; void log_callback(int logLevel, const char *text, va_list args){ char tmpbuf[1024*16]; snprintf(tmpbuf, 1024*16, "%s : %s\n", log_levels[logLevel], text); vfprintf(log_file, tmpbuf, args); } int init_log_file(){ char tmpbuf[4096]; snprintf(tmpbuf, 4096, "%s%s", GetApplicationDirectory(), LOG_PATH); log_file = fopen(tmpbuf, "w"); if(!log_file) return 1; SetTraceLogCallback(log_callback); return 0; } #endif int init(Game *game){ int err; #if DEBUG err = init_log_file(); #endif err |= init_draw(); err |= init_game(game); init_ui(); script_init(game); load_map(game, 0); return err; } void clean(Game *game){ clean_game(game); script_clean(); CloseWindow(); } int main(){ Game game; extern GUIInfo gui_info; gui_info.zoom = &game.camera.zoom; if(init(&game)){ printf("Failed to init game ! Exiting...\n"); clean(&game); return 1; } while(!WindowShouldClose() && !game.exit){ BeginDrawing(); get_keys(&game); update(&game); draw(&game); EndDrawing(); } clean(&game); return 0; }