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; }
int melee_event(scene *scene, SDL_Event *event) { if(event->type == SDL_KEYDOWN) { if (event->key.keysym.sym == SDLK_ESCAPE) { if (selection == 1) { // restore the player selection column_a = player_id_a % 5; row_a = player_id_a / 5; column_b = player_id_b % 5; row_b = player_id_b / 5; selection = 0; done_a = 0; done_b = 0; } else { scene->next_id = SCENE_MENU; } } else { ctrl_event *p1=NULL, *p2 = NULL, *i; controller_event(scene->player1.ctrl, event, &p1); controller_event(scene->player2.ctrl, event, &p2); i = p1; if (i) { do { handle_action(scene, 1, i->action); } while((i = i->next)); DEBUG("done"); } i = p2; if (i) { do { handle_action(scene, 2, i->action); } while((i = i->next)); DEBUG("done"); } } } return 0; }
int intro_event(scene *scene, SDL_Event *event) { 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_ESC || i->event_data.action == ACT_KICK || i->event_data.action == ACT_PUNCH) { game_state_set_next(scene->gs, SCENE_MENU); } } } while((i = i->next)); } controller_free_chain(p1); return 1; }
int newsroom_event(scene *scene, SDL_Event *event) { newsroom_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(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 = HAR_JAGUAR + 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); return 0; }