/* TODO: De-uglify this crap: */ static void init_single_player(Screen *s, TankList *tl, Level *lvl) { Tank *t; Rect gui; unsigned gui_shift; /* Account for the GUI Controller: */ gui = gamelib_gui_get_size(); gui_shift = gui.w + !!gui.w * 15; /* << Shift out of way of thumb... */ gamelib_debug("XYWH: %u %u %u %u", gui.x, gui.y, gui.w, gui.h); /* Ready the tank! */ t = tanklist_add_tank(tl, 0, level_get_spawn(lvl, 0)); gamelib_tank_attach(t, 0, 1); screen_add_window(s, RECT(2, 2, GAME_WIDTH-4, GAME_HEIGHT-6-STATUS_HEIGHT), t); screen_add_status(s, RECT(9 + gui_shift, GAME_HEIGHT - 2 - STATUS_HEIGHT, GAME_WIDTH-12 - gui_shift, STATUS_HEIGHT), t, 1); if(gui_shift) screen_add_controller(s, RECT(3, GAME_HEIGHT - 5 - gui.h, gui.w, gui.h)); /* Add the GUI bitmaps: */ screen_add_bitmap(s, RECT(3 + gui_shift, GAME_HEIGHT - 2 - STATUS_HEIGHT , 4, 5), GUI_ENERGY, &color_status_energy); screen_add_bitmap(s, RECT(3 + gui_shift, GAME_HEIGHT - 2 - STATUS_HEIGHT + 6, 4, 5), GUI_HEALTH, &color_status_health); /* Fill up the rest of the slots with Twitches: */ twitch_fill(tl, lvl, 1); }
static void init_double_player(Screen *s, TankList *tl, Level *lvl) { Tank *t; /* Ready the tanks! */ t = tanklist_add_tank(tl, 0, level_get_spawn(lvl, 0)); gamelib_tank_attach(t, 0, 2); screen_add_window(s, RECT(2, 2, GAME_WIDTH/2-3, GAME_HEIGHT-6-STATUS_HEIGHT), t); screen_add_status(s, RECT(3, GAME_HEIGHT - 2 - STATUS_HEIGHT, GAME_WIDTH/2-5-2, STATUS_HEIGHT), t, 0); /* Load up two controllable tanks: */ t = tanklist_add_tank(tl, 1, level_get_spawn(lvl, 1)); /*controller_twitch_attach(t); << Attach a twitch to a camera tank, so we can see if they're getting smarter... */ gamelib_tank_attach(t, 1, 2); screen_add_window(s, RECT(GAME_WIDTH/2+1, 2, GAME_WIDTH/2-3, GAME_HEIGHT-6-STATUS_HEIGHT), t); screen_add_status(s, RECT(GAME_WIDTH/2+2+2, GAME_HEIGHT - 2 - STATUS_HEIGHT, GAME_WIDTH/2-5-3, STATUS_HEIGHT), t, 1); /* Add the GUI bitmaps: */ screen_add_bitmap(s, RECT(GAME_WIDTH/2-2, GAME_HEIGHT - 2 - STATUS_HEIGHT , 4, 5), GUI_ENERGY, &color_status_energy); screen_add_bitmap(s, RECT(GAME_WIDTH/2-2, GAME_HEIGHT - 2 - STATUS_HEIGHT + 6, 4, 5), GUI_HEALTH, &color_status_health); /* Fill up the rest of the slots with Twitches: */ twitch_fill(tl, lvl, 2); }
static void new_window(struct swc_window *swc) { struct window *window; window = malloc(sizeof *window); if (!window) return; window->swc = swc; window->screen = NULL; swc_window_set_handler(swc, &window_handler, window); swc_window_set_tiled(swc); screen_add_window(active_screen, window); focus(window); }