void melee_free(scene *scene) { melee_local *local = scene_get_userdata(scene); game_player *player2 = game_state_get_player(scene->gs, 1); surface_free(&local->feh); surface_free(&local->bleh); surface_free(&local->select_hilight); for(int i = 0; i < 2; i++) { component_free(local->bar_power[i]); component_free(local->bar_agility[i]); component_free(local->bar_endurance[i]); } for(int i = 0; i < 10; i++) { object_free(&local->pilots[i]); object_free(&local->harportraits_player1[i]); object_free(&local->har_player1[i]); if (player2->selectable) { object_free(&local->harportraits_player2[i]); object_free(&local->har_player2[i]); } } object_free(&local->player2_placeholder); object_free(&local->unselected_har_portraits); object_free(&local->bigportrait1); if (player2->selectable) { object_free(&local->bigportrait2); } free(local); }
void intro_tick(scene *scene, int paused) { intro_local *local = scene_get_userdata(scene); local->ticks++; if(local->ticks > 2500) { game_state_set_next(scene->gs, SCENE_MENU); } }
void render_highlights(scene *scene) { melee_local *local = scene_get_userdata(scene); game_player *player2 = game_state_get_player(scene->gs, 1); int trans; if (player2->selectable && local->row_a == local->row_b && local->column_a == local->column_b) { video_render_sprite_tint(&local->select_hilight, 11 + (62*local->column_a), 115 + (42*local->row_a), color_create(250-local->ticks, 0, 250-local->ticks, 0), 0); } else { if (player2->selectable) { if (local->done_b) { trans = 250; } else { trans = 250 - local->ticks; } video_render_sprite_tint(&local->select_hilight, 11 + (62*local->column_b), 115 + (42*local->row_b), color_create(0, 0, trans, 0), 0); } if (local->done_a) { trans = 250; } else { trans = 250 - local->ticks; } video_render_sprite_tint(&local->select_hilight, 11 + (62*local->column_a), 115 + (42*local->row_a), color_create(trans, 0, 0, 0), 0); } }
void vs_handle_action(scene *scene, int action) { vs_local *local = scene_get_userdata(scene); if(dialog_is_visible(&local->too_pathetic_dialog)) { dialog_event(&local->too_pathetic_dialog, action); } else if(dialog_is_visible(&local->quit_dialog)) { dialog_event(&local->quit_dialog, action); } else { switch (action) { case ACT_KICK: case ACT_PUNCH: game_state_set_next(scene->gs, SCENE_ARENA0+local->arena); break; case ACT_UP: case ACT_LEFT: if(game_state_get_player(scene->gs, 1)->selectable) { local->arena--; if (local->arena < 0) { local->arena =4; } object_select_sprite(&local->arena_select, local->arena); } break; case ACT_DOWN: case ACT_RIGHT: if(game_state_get_player(scene->gs, 1)->selectable) { local->arena++; if (local->arena > 4) { local->arena = 0; } object_select_sprite(&local->arena_select, local->arena); } break; } } }
int cutscene_event(scene *scene, SDL_Event *event) { cutscene_local *local = scene_get_userdata(scene); game_player *player1 = game_state_get_player(scene->gs, 0); ctrl_event *p1=NULL, *i; controller_event(player1->ctrl, event, &p1); i = p1; if (i) { do { if(i->type == EVENT_TYPE_ACTION) { if ( i->event_data.action == ACT_KICK || i->event_data.action == ACT_PUNCH) { if (strlen(local->current) + local->pos < local->len) { local->pos += strlen(local->current)+1; local->current += strlen(local->current)+1; char * p; if ((p = strchr(local->current, '\n'))) { // null out the byte *p = '\0'; } } else { game_state_set_next(scene->gs, cutscene_next_scene(scene)); } return 1; } } } while((i = i->next)); } controller_free_chain(p1); return 1; }
void mechlab_input_tick(scene *scene) { mechlab_local *local = scene_get_userdata(scene); game_player *player1 = game_state_get_player(scene->gs, 0); // Poll the controller ctrl_event *p1 = NULL, *i; controller_poll(player1->ctrl, &p1); i = p1; if(i) { do { if(i->type == EVENT_TYPE_ACTION) { // If view is new dashboard view, pass all input to it if(local->dashtype == DASHBOARD_NEW) { // If inputting text for new player name is done, switch to next view. // If ESC, exit view. // Otherwise handle text input if(i->event_data.action == ACT_ESC) { trnmenu_finish(guiframe_get_root(local->frame)); } else if(i->event_data.action == ACT_KICK || i->event_data.action == ACT_PUNCH) { mechlab_select_dashboard(scene, local, DASHBOARD_SELECT_NEW_PIC); trnmenu_finish(guiframe_get_root(local->frame)); // This will trigger exception case in mechlab_tick } else { guiframe_action(local->dashboard, i->event_data.action); } // If view is any other, just pass input to the bottom menu } else { guiframe_action(local->frame, i->event_data.action); } } } while((i = i->next)); } controller_free_chain(p1); }
void scoreboard_render_overlay(scene *scene) { scoreboard_local *local = scene_get_userdata(scene); video_render_sprite_size(&local->black_surface, 0, 0, 320, 200); char row[128]; char score_text[15]; char temp_name[17]; const char* score_row_format = "%-18s%-9s%-9s%11s"; // Header text sprintf(row, "SCOREBOARD - %s", round_get_name(local->page)); int title_x = 62 + (local->page == 0 ? 8 : 0); font_render(&font_large, row, title_x, 5, TEXT_COLOR_HEADER); // Column names sprintf(row, score_row_format, "PLAYER NAME", "ROBOT", "PILOT", "SCORE"); font_render(&font_small, row, 20, 20, TEXT_COLOR_HEADER); // Scores information unsigned int score, har_id, pilot_id; char *player_name; int entry = 0; int found_slot = 0; for(int r = 0; r < 20; r++) { score = local->data.entries[local->page][entry].score; row[0] = 0; // If this slot is the slot where the new, pending score data should be written, // show pending data and text input field. Otherwise just show next line of // original saved score data. if(local->has_pending_data && score < local->pending_data.score && !found_slot) { sprintf(temp_name, "%s%s", local->pending_data.name, CURSOR_STR); score_format(local->pending_data.score, score_text); sprintf(row, score_row_format, temp_name, har_get_name(local->pending_data.har_id), pilot_get_name(local->pending_data.pilot_id), score_text); found_slot = 1; } else { har_id = local->data.entries[local->page][entry].har_id; pilot_id = local->data.entries[local->page][entry].pilot_id; player_name = local->data.entries[local->page][entry].name; if(score > 0) { score_format(score, score_text); sprintf(row, score_row_format, player_name, har_get_name(har_id), pilot_get_name(pilot_id), score_text); } entry++; } font_render(&font_small, row, 20, 30 + r*8, TEXT_COLOR_SCORES); } }
void vs_render_overlay(scene *scene) { vs_local *local = scene_get_userdata(scene); if(dialog_is_visible(&local->quit_dialog)) { dialog_render(&local->quit_dialog); } if(dialog_is_visible(&local->too_pathetic_dialog)) { dialog_render(&local->too_pathetic_dialog); } }
// newsroom callbacks void newsroom_free(scene *scene) { newsroom_local *local = scene_get_userdata(scene); surface_free(&local->news_bg); str_free(&local->news_str); str_free(&local->pilot1); str_free(&local->pilot2); str_free(&local->har1); str_free(&local->har2); dialog_free(&local->continue_dialog); free(local); }
void melee_tick(scene *scene, int paused) { melee_local *local = scene_get_userdata(scene); game_player *player1 = game_state_get_player(scene->gs, 0); game_player *player2 = game_state_get_player(scene->gs, 1); ctrl_event *i = NULL; // Handle extra controller inputs i = player1->ctrl->extra_events; if (i) { do { if(i->type == EVENT_TYPE_ACTION) { handle_action(scene, 1, i->event_data.action); } else if (i->type == EVENT_TYPE_CLOSE) { game_state_set_next(scene->gs, SCENE_MENU); return; } } while((i = i->next)); } i = player2->ctrl->extra_events; if (i) { do { if(i->type == EVENT_TYPE_ACTION) { handle_action(scene, 2, i->event_data.action); } else if (i->type == EVENT_TYPE_CLOSE) { game_state_set_next(scene->gs, SCENE_MENU); return; } } while((i = i->next)); } if(!local->pulsedir) { local->ticks++; } else { local->ticks--; } if(local->ticks > 120) { local->pulsedir = 1; } if(local->ticks == 0) { local->pulsedir = 0; } local->hartick++; if (local->selection == 1) { if(local->hartick > 10) { local->hartick = 0; object_dynamic_tick(&local->har_player1[5*local->row_a + local->column_a]); if (player2->selectable) { object_dynamic_tick(&local->har_player2[5*local->row_b + local->column_b]); } } } }
void mechlab_free(scene *scene) { mechlab_local *local = scene_get_userdata(scene); for(int i = 0; i < sizeof(local->bg_obj)/sizeof(object); i++) { object_free(&local->bg_obj[i]); } guiframe_free(local->frame); guiframe_free(local->dashboard); object_free(local->mech); free(local->mech); free(local); }
void mechlab_render(scene *scene) { mechlab_local *local = scene_get_userdata(scene); for(int i = 0; i < sizeof(local->bg_obj)/sizeof(object); i++) { object_render(&local->bg_obj[i]); } // Render dashboard guiframe_render(local->frame); guiframe_render(local->dashboard); // Only render mech in stats dashboard if(local->dashtype == DASHBOARD_STATS) { object_render(local->mech); } }
int mechlab_event(scene *scene, SDL_Event *event) { mechlab_local *local = scene_get_userdata(scene); game_player *player1 = game_state_get_player(scene->gs, 0); if (player1->ctrl->type == CTRL_TYPE_GAMEPAD || (player1->ctrl->type == CTRL_TYPE_KEYBOARD && event->type == SDL_KEYDOWN && keyboard_binds_key(player1->ctrl, event))) { // these events will be handled by polling return 1; } if(local->dashtype == DASHBOARD_NEW) { return guiframe_event(local->dashboard, event); } else { return guiframe_event(local->frame, event); } }
void vs_free(scene *scene) { vs_local *local = scene_get_userdata(scene); game_player *player2 = game_state_get_player(scene->gs, 1); dialog_free(&local->quit_dialog); dialog_free(&local->too_pathetic_dialog); surface_free(&local->arena_select_bg); object_free(&local->player1_portrait); object_free(&local->player2_portrait); object_free(&local->player1_har); object_free(&local->player2_har); if (player2->selectable) { object_free(&local->arena_select); } free(local); }
void melee_input_tick(scene *scene) { melee_local *local = scene_get_userdata(scene); game_player *player1 = game_state_get_player(scene->gs, 0); game_player *player2 = game_state_get_player(scene->gs, 1); ctrl_event *p1=NULL, *p2 = NULL, *i; controller_poll(player1->ctrl, &p1); controller_poll(player2->ctrl, &p2); i = p1; if (i) { do { if(i->type == EVENT_TYPE_ACTION) { if (i->event_data.action == ACT_ESC) { sound_play(20, 0.5f, 0.0f, 2.0f); if (local->selection == 1) { // restore the player selection local->column_a = local->pilot_id_a % 5; local->row_a = local->pilot_id_a / 5; local->column_b = local->pilot_id_b % 5; local->row_b = local->pilot_id_b / 5; local->selection = 0; local->done_a = 0; local->done_b = 0; } else { game_state_set_next(scene->gs, SCENE_MENU); } } else { handle_action(scene, 1, i->event_data.action); } } else if (i->type == EVENT_TYPE_CLOSE) { game_state_set_next(scene->gs, SCENE_MENU); } } while((i = i->next)); } controller_free_chain(p1); i = p2; if (i) { do { if(i->type == EVENT_TYPE_ACTION) { handle_action(scene, 2, i->event_data.action); } else if (i->type == EVENT_TYPE_CLOSE) { game_state_set_next(scene->gs, SCENE_MENU); } } while((i = i->next)); } controller_free_chain(p2); }
void scoreboard_input_tick(scene*scene) { scoreboard_local *local = scene_get_userdata(scene); game_player *player1 = game_state_get_player(scene->gs, 0); ctrl_event *p1 = NULL, *i; controller_poll(player1->ctrl, &p1); i = p1; if(i) { do { if(i->type == EVENT_TYPE_ACTION) { // If there is pending data, and name has been given, save if(local->has_pending_data && strlen(local->pending_data.name) > 0 && (i->event_data.action == ACT_KICK || i->event_data.action == ACT_PUNCH)) { handle_scoreboard_save(local); local->has_pending_data = 0; // If there is no data, and confirm is clicked, don't save } else if (local->has_pending_data == 1 && strlen(local->pending_data.name) == 0 && (i->event_data.action == ACT_KICK || i->event_data.action == ACT_PUNCH)) { local->has_pending_data = 0; // Normal exit routine // Only allow if there is no pending data. } else if(!local->has_pending_data && (i->event_data.action == ACT_ESC || i->event_data.action == ACT_KICK || i->event_data.action == ACT_PUNCH)) { game_state_set_next(scene->gs, scene->gs->next_next_id); // If left or right button is pressed, change page // but only if we are not in input mode. } else if(!local->has_pending_data && i->event_data.action == ACT_LEFT) { local->page = (local->page > 0) ? local->page-1 : 0; } else if(!local->has_pending_data && i->event_data.action == ACT_RIGHT) { local->page = (local->page < MAX_PAGES) ? local->page+1 : MAX_PAGES; } } } while((i = i->next)); } controller_free_chain(p1); }
void mechlab_tick(scene *scene, int paused) { mechlab_local *local = scene_get_userdata(scene); guiframe_tick(local->frame); guiframe_tick(local->dashboard); object_dynamic_tick(local->mech); // Check if root is finished component *root = guiframe_get_root(local->frame); if(trnmenu_is_finished(root)) { if(local->dashtype == DASHBOARD_SELECT_NEW_PIC) { guiframe_free(local->frame); local->frame = guiframe_create(0, 0, 320, 200); guiframe_set_root(local->frame, lab_menu_pilotselect_create(scene, &local->dw)); guiframe_layout(local->frame); } else { game_state_set_next(scene->gs, SCENE_MENU); } } }
void vs_render(scene *scene) { vs_local *local = scene_get_userdata(scene); game_player *player1 = game_state_get_player(scene->gs, 0); game_player *player2 = game_state_get_player(scene->gs, 1); // player 1 HAR object_render(&local->player1_har); // player 2 HAR object_render(&local->player2_har); // player 1 portrait object_render(&local->player1_portrait); // player 2 portrait object_render(&local->player2_portrait); font_render_shadowed(&font_small, local->vs_str, 160-((strlen(local->vs_str)*font_small.w)/2), 0, COLOR_YELLOW, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); if (player2->selectable) { // arena selection video_render_sprite(&local->arena_select_bg, 55, 150, BLEND_ALPHA, 0); object_render(&local->arena_select); // arena name font_render_wrapped(&font_small, lang_get(56+local->arena), 56+72, 153, (211-72)-4, COLOR_GREEN); // arena description font_render_wrapped(&font_small, lang_get(66+local->arena), 56+72, 160, (211-72)-4, COLOR_GREEN); } else if (player2->pilot_id == 10 && settings_get()->gameplay.difficulty < 2) { // kriessack, but not on Veteran or higher font_render_wrapped(&font_small, lang_get(747), 59, 160, 200, COLOR_YELLOW); } else { font_render_wrapped(&font_small, lang_get(749+(11*player1->pilot_id)+player2->pilot_id), 59, 160, 150, COLOR_YELLOW); font_render_wrapped(&font_small, lang_get(870+(11*player2->pilot_id)+player1->pilot_id), 320-(59+150), 180, 150, COLOR_YELLOW); } }
int scoreboard_event(scene *scene, SDL_Event *event) { scoreboard_local *local = scene_get_userdata(scene); // If we are in writing mode, try handling text input if(local->has_pending_data && event->type == SDL_KEYDOWN) { unsigned char code = event->key.keysym.sym; unsigned char len = strlen(local->pending_data.name); unsigned char scancode = event->key.keysym.scancode; if(scancode == SDL_SCANCODE_BACKSPACE || scancode == SDL_SCANCODE_DELETE) { if(len > 0) { local->pending_data.name[len-1] = 0; } return 1; } else if(code >= 32 && code <= 126) { if(len < sizeof(local->pending_data.name)-1) { local->pending_data.name[len+1] = 0; local->pending_data.name[len] = code; } return 1; } } return 1; }
void newsroom_overlay_render(scene *scene) { newsroom_local *local = scene_get_userdata(scene); // Render screencapture har_screencaps *caps = &(game_state_get_player(scene->gs, (local->won ? 0 : 1))->screencaps); if(local->screen == 0) { if(caps->ok[SCREENCAP_POSE]) video_render_sprite_size(&caps->cap[SCREENCAP_POSE], 165, 15, SCREENCAP_W, SCREENCAP_H); } else { if(caps->ok[SCREENCAP_BLOW]) video_render_sprite_size(&caps->cap[SCREENCAP_BLOW], 165, 15, SCREENCAP_W, SCREENCAP_H); } // Render text if(str_size(&local->news_str) > 0) { video_render_sprite(&local->news_bg, 20, 140, BLEND_ALPHA, 0); font_render_wrapped(&font_small, str_c(&local->news_str), 30, 150, 250, COLOR_YELLOW); } // Dialog if(dialog_is_visible(&local->continue_dialog)) { dialog_render(&local->continue_dialog); } }
void scoreboard_free(scene *scene) { scoreboard_local *local = scene_get_userdata(scene); surface_free(&local->black_surface); free(local); }
void melee_render(scene *scene) { melee_local *local = scene_get_userdata(scene); game_player *player2 = game_state_get_player(scene->gs, 1); int current_a = 5*local->row_a + local->column_a; int current_b = 5*local->row_b + local->column_b; if (local->selection == 0) { video_render_sprite(&local->feh, 70, 0, BLEND_ALPHA, 0); video_render_sprite(&local->bleh, 0, 62, BLEND_ALPHA, 0); // player bio font_render_wrapped_shadowed(&font_small, lang_get(135+current_a), 4, 66, 152, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); // player stats font_render_shadowed(&font_small, lang_get(216), 74+27, 4, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); font_render_shadowed(&font_small, lang_get(217), 74+19, 22, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); font_render_shadowed(&font_small, lang_get(218), 74+12, 40, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); component_render(local->bar_power[0]); component_render(local->bar_agility[0]); component_render(local->bar_endurance[0]); if (player2->selectable) { video_render_sprite(&local->feh, 320-70-local->feh.w, 0, BLEND_ALPHA, 0); video_render_sprite(&local->bleh, 320-local->bleh.w, 62, BLEND_ALPHA, 0); // player bio font_render_wrapped_shadowed(&font_small, lang_get(135+current_b), 320-local->bleh.w+4, 66, 152, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); // player stats font_render_shadowed(&font_small, lang_get(216), 320-66-local->feh.w+27, 4, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); font_render_shadowed(&font_small, lang_get(217), 320-66-local->feh.w+19, 22, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); font_render_shadowed(&font_small, lang_get(218), 320-66-local->feh.w+12, 40, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); component_render(local->bar_power[1]); component_render(local->bar_agility[1]); component_render(local->bar_endurance[1]); } else { // 'choose your pilot' font_render_wrapped_shadowed(&font_small, lang_get(187), 160, 97, 160, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); } } object_render(&local->player2_placeholder); if (local->selection == 0) { // player 1 name font_render_wrapped_shadowed(&font_small, lang_get(20+current_a), 0, 52, 66, COLOR_BLACK, TEXT_SHADOW_TOP|TEXT_SHADOW_LEFT); if (player2->selectable) { // player 2 name font_render_wrapped_shadowed(&font_small, lang_get(20+current_b), 320-66, 52, 66, COLOR_BLACK, TEXT_SHADOW_TOP|TEXT_SHADOW_LEFT); } render_highlights(scene); for(int i = 0; i < 10; i++) { object_render(&local->pilots[i]); } object_render(&local->bigportrait1); if (player2->selectable) { object_render(&local->bigportrait2); } } else { // render the stupid unselected HAR portraits before anything // so we can render anything else on top of them object_render(&local->unselected_har_portraits); render_highlights(scene); // currently selected player object_render(&local->bigportrait1); //currently selected HAR object_render(&local->harportraits_player1[5*local->row_a + local->column_a]); object_render(&local->har_player1[5*local->row_a + local->column_a]); // player 1 name font_render_wrapped_shadowed(&font_small, lang_get(20+local->pilot_id_a), 0, 52, 66, COLOR_BLACK, TEXT_SHADOW_TOP|TEXT_SHADOW_LEFT); if (player2->selectable) { // player 2 name font_render_wrapped_shadowed(&font_small, lang_get(20+local->pilot_id_b), 320-66, 52, 66, COLOR_BLACK, TEXT_SHADOW_TOP|TEXT_SHADOW_LEFT); // currently selected player object_render(&local->bigportrait2); // currently selected HAR object_render(&local->harportraits_player2[5*local->row_b + local->column_b]); object_render(&local->har_player2[5*local->row_b + local->column_b]); // render HAR name (Har1 VS. Har2) char vstext[48]; strcpy(vstext, har_get_name(5*local->row_a + local->column_a)); strcat(vstext, " VS. "); strcat(vstext, har_get_name(5*local->row_b + local->column_b)); font_render_wrapped_shadowed(&font_small, vstext, 80, 107, 150, COLOR_BLACK, TEXT_SHADOW_TOP|TEXT_SHADOW_LEFT); } else { // 'choose your HAR' font_render_wrapped_shadowed(&font_small, lang_get(186), 160, 97, 160, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); // render HAR name font_render_wrapped_shadowed(&font_small, har_get_name(5*local->row_a + local->column_a), 130, 107, 66, COLOR_BLACK, TEXT_SHADOW_TOP|TEXT_SHADOW_LEFT); } } if (player2->selectable) { chr_score *s1 = game_player_get_score(game_state_get_player(scene->gs, 0)); chr_score *s2 = game_player_get_score(game_state_get_player(scene->gs, 1)); char winstext[48]; snprintf(winstext, 48, "Wins: %d", s1->wins); font_render_shadowed(&font_small, winstext, 8, 107, COLOR_BLACK, TEXT_SHADOW_TOP|TEXT_SHADOW_LEFT); snprintf(winstext, 48, "Wins: %d", s2->wins); font_render_shadowed(&font_small, winstext, 312-(strlen(winstext)*font_small.w), 107, COLOR_BLACK, TEXT_SHADOW_TOP|TEXT_SHADOW_LEFT); } }
void newsroom_input_tick(scene *scene) { newsroom_local *local = scene_get_userdata(scene); game_player *player1 = game_state_get_player(scene->gs, 0); ctrl_event *p1=NULL, *i; controller_poll(player1->ctrl, &p1); i = p1; if (i) { do { if(i->type == EVENT_TYPE_ACTION) { if(dialog_is_visible(&local->continue_dialog)) { dialog_event(&local->continue_dialog, i->event_data.action); } else if ( i->event_data.action == ACT_ESC || i->event_data.action == ACT_KICK || i->event_data.action == ACT_PUNCH) { local->screen++; newsroom_fixup_str(local); if(local->screen >= 2) { if (local->won) { // pick a new player game_player *p1 = game_state_get_player(scene->gs, 0); game_player *p2 = game_state_get_player(scene->gs, 1); DEBUG("wins are %d", p1->sp_wins); if (p1->sp_wins == (4094 ^ (2 << p1->pilot_id))) { // won the game game_state_set_next(scene->gs, SCENE_END); } else { if (p1->sp_wins == (2046 ^ (2 << p1->pilot_id))) { // everyone but kriessack p2->pilot_id = 10; p2->har_id = HAR_NOVA; } else { // pick an opponent we have not yet beaten while(1) { int i = rand_int(10); if ((2 << i) & p1->sp_wins || i == p1->pilot_id) { continue; } p2->pilot_id = i; p2->har_id = rand_int(10); break; } } pilot p; pilot_get_info(&p, p2->pilot_id); p2->colors[0] = p.colors[0]; p2->colors[1] = p.colors[1]; p2->colors[2] = p.colors[2]; // make a new AI controller controller *ctrl = malloc(sizeof(controller)); controller_init(ctrl); ai_controller_create(ctrl, settings_get()->gameplay.difficulty); game_player_set_ctrl(p2, ctrl); game_state_set_next(scene->gs, SCENE_VS); } } else { dialog_show(&local->continue_dialog, 1); } } } } } while((i = i->next)); } controller_free_chain(p1); }
void cutscene_render_overlay(scene *scene) { cutscene_local *local = scene_get_userdata(scene); text_render(&local->text_conf, local->text_x, local->text_y, local->text_width, 200, local->current); }
void handle_action(scene *scene, int player, int action) { game_player *player1 = game_state_get_player(scene->gs, 0); game_player *player2 = game_state_get_player(scene->gs, 1); melee_local *local = scene_get_userdata(scene); int *row, *column, *done; if (player == 1) { row = &local->row_a; column = &local->column_a; done = &local->done_a; } else { row = &local->row_b; column = &local->column_b; done = &local->done_b; } if (*done) { return; } switch (action) { case ACT_LEFT: (*column)--; if (*column < 0) { *column = 4; } sound_play(19, 0.5f, 0.0f, 2.0f); break; case ACT_RIGHT: (*column)++; if (*column > 4) { *column = 0; } sound_play(19, 0.5f, 0.0f, 2.0f); break; case ACT_UP: if(*row == 1) { *row = 0; } sound_play(19, 0.5f, 0.0f, 2.0f); break; case ACT_DOWN: if(*row == 0) { *row = 1; } // nova selection cheat if(*row == 1 && *column == 0) { local->katana_down_count[player-1]++; if(local->katana_down_count[player-1] > 11) { local->katana_down_count[player-1] = 11; } } sound_play(19, 0.5f, 0.0f, 2.0f); break; case ACT_KICK: case ACT_PUNCH: *done = 1; sound_play(20, 0.5f, 0.0f, 2.0f); if (local->done_a && (local->done_b || !player2->selectable)) { local->done_a = 0; local->done_b = 0; if (local->selection == 0) { local->selection = 1; local->pilot_id_a = 5*local->row_a + local->column_a; local->pilot_id_b = 5*local->row_b + local->column_b; // nova selection cheat local->har_selected[0][local->pilot_id_a] = 1; local->har_selected[1][local->pilot_id_b] = 1; object_select_sprite(&local->bigportrait1, local->pilot_id_a); // update the player palette palette *base_pal = video_get_base_palette(); pilot p_a; pilot_get_info(&p_a, local->pilot_id_a); palette_set_player_color(base_pal, 0, p_a.colors[0], 2); palette_set_player_color(base_pal, 0, p_a.colors[1], 1); palette_set_player_color(base_pal, 0, p_a.colors[2], 0); video_force_pal_refresh(); player1->colors[0] = p_a.colors[0]; player1->colors[1] = p_a.colors[1]; player1->colors[2] = p_a.colors[2]; if (player2->selectable) { object_select_sprite(&local->bigportrait2, local->pilot_id_b); // update the player palette pilot_get_info(&p_a, local->pilot_id_b); palette_set_player_color(base_pal, 1, p_a.colors[0], 2); palette_set_player_color(base_pal, 1, p_a.colors[1], 1); palette_set_player_color(base_pal, 1, p_a.colors[2], 0); video_force_pal_refresh(); player2->colors[0] = p_a.colors[0]; player2->colors[1] = p_a.colors[1]; player2->colors[2] = p_a.colors[2]; } } else { int nova_activated[2] = {1, 1}; for(int i = 0;i < 2;i++) { for(int j = 0;j < 10;j++) { if(local->har_selected[i][j] == 0) { nova_activated[i] = 0; break; } } if(local->katana_down_count[i] < 11) { nova_activated[i] = 0; } } if(nova_activated[0] && local->row_a == 1 && local->column_a == 2) { player1->har_id = HAR_NOVA; } else { player1->har_id = 5*local->row_a+local->column_a; } player1->pilot_id = local->pilot_id_a; if (player2->selectable) { if(nova_activated[1] && local->row_b == 1 && local->column_b == 2) { player2->har_id = HAR_NOVA; } else { player2->har_id = 5*local->row_b+local->column_b; } player2->pilot_id = local->pilot_id_b; } else { if (player1->sp_wins == (2046 ^ (2 << player1->pilot_id))) { // everyone but kriessack player2->pilot_id = 10; player2->har_id = HAR_NOVA; } else { // pick an opponent we have not yet beaten while(1) { int i = rand_int(10); if ((2 << i) & player1->sp_wins || i == player1->pilot_id) { continue; } player2->pilot_id = i; player2->har_id = rand_int(10); break; } } pilot p_a; pilot_get_info(&p_a, player2->pilot_id); player2->colors[0] = p_a.colors[0]; player2->colors[1] = p_a.colors[1]; player2->colors[2] = p_a.colors[2]; } game_state_set_next(scene->gs, SCENE_VS); } } break; } if(local->selection == 0) { object_select_sprite(&local->bigportrait1, 5*local->row_a + local->column_a); if (player2->selectable) { object_select_sprite(&local->bigportrait2, 5*local->row_b + local->column_b); } } // nova selection cheat if(local->selection == 1) { local->har_selected[player-1][5 * (*row) + *column] = 1; } refresh_pilot_stats(local); }
void intro_free(scene *scene) { free(scene_get_userdata(scene)); }
void cutscene_render_overlay(scene *scene) { cutscene_local *local = scene_get_userdata(scene); font_render_wrapped(&font_small, local->current, local->text_x, local->text_y, local->text_width, local->color); }
void cutscene_free(scene *scene) { free(scene_get_userdata(scene)); }
void newsroom_static_tick(scene *scene, int paused) { newsroom_local *local = scene_get_userdata(scene); dialog_tick(&local->continue_dialog); }
void cutscene_free(scene *scene) { cutscene_local *local = scene_get_userdata(scene); free(local->text); free(local); }