void start_new_round() { holenum_index = 0; text_layer_set_text(&holepar_hole_num, s_holenum[holenum_index]); // Start Round timer totalshots = -1; thishole = -1; update_shot(); club_menu_index = 1; text_layer_set_text(&club, club_menu[club_menu_index]); round_started = true; mini_snprintf(s_roundtime, 25, "Round Time: %02d:%02d", 0, 0); text_layer_set_text(&roundtime, s_roundtime); PblTm roundstarttime; get_time(&roundstarttime); round_start_hour = roundstarttime.tm_hour; round_start_minute = roundstarttime.tm_min; }
void select_single_click_handler(ClickRecognizerRef recognizer, Window *window) { (void)recognizer; (void)window; switch (club_menu_index) { case 0 : { /* Start Round*/ if (round_started == false) { start_new_round(); } break; } case 14 : { /* Next Hole*/ thishole = 0; mini_snprintf(s_shots_hole, 25, "Shots: %d", thishole); text_layer_set_text(&shots_hole, s_shots_hole); update_holepar(); club_menu_index = 1; text_layer_set_text(&club, club_menu[club_menu_index]); break; } // case 15 : { /* Previous Hole */ // break; // } case 15 : { /* End Round*/ // Stop Round Timer // Clear hole par // Add new layer with final score big? end_round(); break; } default : { /* Record Shot*/ save_clubinfo(); update_shot(); } } }
int game(int type){ int game_over = 0; { surface *background = new_image("background.png"); apply_texture(background, window); destroy_surface(background); } initialize_cameras();initialize_star();initialize_ships(2);initialize_dust(); initialize_shot();initialize_ai(); play_music("music.ogg"); draw_tank(0, (window_width / 2 - 421), window_height / 2 - 150); draw_tank(1, window_width / 2 + 401, window_height / 2 - 150); // Main loop for(;;){ int i; get_input(); if(keyboard[ESC] || game_over){ break; } for(i = 0; i < 2; i ++) if(ship[i].status == DEAD){ struct timeval now; gettimeofday(&now, NULL); if((int) (now.tv_sec - ship[i].time.tv_sec) > 2) game_over = 1; } erase_ships(); erase_shot(); if(type != CPU_X_CPU){ // Rotation: 10 Propulse: 20 Fire: 20 Hyper: 180 int my_ship; // Player 1 moves if(type == CPU_X_PLR){ ai_play(0); my_ship = 1; } else if(type == PLR_X_CPU){ my_ship = 0; ai_play(1); } else my_ship = 0; if(keyboard[LEFT]) rotate_ship(my_ship, LEFT); if(keyboard[RIGHT]) rotate_ship(my_ship, RIGHT); if(keyboard[UP]) propulse_ship(my_ship); if(keyboard[DOWN]) ship_fire(my_ship); if(keyboard[RIGHT_CTRL]) goto_hyperspace(my_ship); } else{ ai_play(0); ai_play(1); } if(type == PLR_X_PLR){ // Player 2 moves if(keyboard[A]) rotate_ship(1, LEFT); if(keyboard[D]) rotate_ship(1, RIGHT); if(keyboard[W]) propulse_ship(1); if(keyboard[L]) blow_up(1); if(keyboard[S]) ship_fire(1); if(keyboard[LEFT_CTRL]) goto_hyperspace(1); } update_star(); // 6 update_ships(); // 2 update_dust(); // 145 update_shot(); // 16 film_ships(); // Até 16 film_dust(); // 20 film_shot(); // Até 20 weaver_rest(10000000); } stop_music(); destroy_star(); destroy_ships(); destroy_cameras(); destroy_dust(); destroy_shot(); clean_keyboard(); return 0; }