// switch between gamestates void switchgs(enum GameState newgs) { FastClearScreen_R(lightbuffer); FastClearScreen_R(darkbuffer); birdframe = 0; // deinitialize switch (gs) { case GS_MENU: menu_deinit(newgs); break; case GS_GAME: game_deinit(newgs); break; case GS_GAMEOVER: gameover_deinit(newgs); break; default: break; } // initialize switch (newgs) { case GS_MENU: menu_init(gs); break; case GS_GAME: game_init(gs); break; case GS_GAMEOVER: gameover_init(gs); break; default: break; } gs = newgs; }
void view_init() { sidebar_width=platform_lowres?3*SIDEBAR_WIDTH_MAX/4:SIDEBAR_WIDTH_MAX; font_std=d_font_load("res/FreeMonoBold.ttf", platform_lowres?8:12, 512, 512); mouse_tilesheet=d_render_tilesheet_load("res/mouse.png", 16, 16, DARNIT_PFORMAT_RGB5A1); mouse_target_tilesheet=d_render_tilesheet_load("res/target.png", 32, 32, DARNIT_PFORMAT_RGB5A1); //Menu background int scale=config.plasma==0?1:(1<<(5-config.plasma)); view_background_w=platform.screen_w/scale; view_background_h=platform.screen_h/scale; view_background_ts=d_render_tilesheet_new(1, 1, view_background_w, view_background_h, DARNIT_PFORMAT_RGB5A1); view_background_tile=d_render_tile_new(1, view_background_ts); view_background_pixbuf=malloc(view_background_w*view_background_h*sizeof(unsigned int)); d_render_tilesheet_scale_algorithm(view_background_ts, DARNIT_SCALE_LINEAR); d_render_tile_move(view_background_tile, 0, 0, 0); d_render_tile_tilesheet_coord_set(view_background_tile, 0, 0, 0, view_background_w, view_background_h); d_render_tile_size_set(view_background_tile, 0, platform.screen_w, platform.screen_h); view_background_update(0); menu_init(); lobby_init(); game_view_init(); gameover_init(); chat_init(); gamestate_pane[GAME_STATE_MENU]=&panelist_menu_sidebar; gamestate_pane[GAME_STATE_CREDITS]=&panelist_credits; gamestate_pane[GAME_STATE_CONNECTING]=&panelist_multiplayer_connecting; gamestate_pane[GAME_STATE_LOBBY]=&panelist_lobby_players; gamestate_pane[GAME_STATE_GAME]=&panelist_game_sidebar; gamestate_pane[GAME_STATE_GAME_MENU]=&panelist_game_menu; gamestate_pane[GAME_STATE_GAME_OVER]=&panelist_gameover_sidebar; gamestate_pane[GAME_STATE_QUIT]=NULL; map=NULL; }