// Main function int main(int argc, char **argv) { #if HGW_FUNC hgw_context = hgw_context_compat_init(argc, argv); if (!hgw_context) { fprintf(stderr, "Cannot init hildon-games-startup!\n"); return 0; } hgw_compat_set_cb_exit(hgw_context, exit_callback); hgw_compat_set_cb_quit(hgw_context, quit_callback); hgw_compat_set_cb_flush(hgw_context, flush_callback); if(!hgw_context_compat_check(hgw_context)) return 0; /* hildon-games-wrapper part */ hgw_msg_compat_receive(hgw_context, 0); usleep(100); #endif // Initialize SDL if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) { fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return 0; } // Initialize video screen = SDL_SetVideoMode(800, 480, 16, SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_FULLSCREEN); if (screen == NULL) { fprintf(stderr, "Unable to set 800x480 video: %s\n", SDL_GetError()); return 0; } SDL_ShowCursor(SDL_DISABLE); SDL_WM_SetCaption("Battle Gweled", NULL); // Load images if (!load_surfaces()) { free_surfaces(); SDL_Quit(); fprintf(stderr, "Unable to load images!\n"); return 0; } // Initialize game srand(time(NULL)); mutex = SDL_CreateMutex(); show_menu_loop(); SDL_DestroyMutex(mutex); #if HGW_FUNC if (game_state.state == GAME_LOSE) hgw_context_destroy(hgw_context, HGW_BYE_INACTIVE); else hgw_context_destroy(hgw_context, HGW_BYE_PAUSED); #endif // Finalize game free_surfaces(); SDL_Quit(); return 0; }
void MG_quit () { MG_drawing_stack_free (); free_surfaces (); free_audio (); free_animations (); free_ttfs (); Mix_HaltMusic (); SDL_FreeSurface( machine->game_world ); SDL_Quit (); TTF_Quit (); }