static boolean load_world_gameplay(struct game_context *game, char *name) { struct world *mzx_world = ((context *)game)->world; boolean was_faded = get_fade_status(); boolean ignore; struct board *cur_board; // Save the name of the current playing mod; we'll want it to continue playing // into gameplay if the first board has the same mod or mod *. char old_mod_playing[MAX_PATH]; strcpy(old_mod_playing, mzx_world->real_mod_playing); load_vquick_fadeout(); clear_screen(); game->fade_in = true; if(reload_world(mzx_world, name, &ignore)) { if(mzx_world->current_board_id != mzx_world->first_board) { change_board(mzx_world, mzx_world->first_board); } cur_board = mzx_world->current_board; // Send both JUSTENTERED and JUSTLOADED; the JUSTLOADED label will // take priority if a robot defines it. send_robot_def(mzx_world, 0, LABEL_JUSTENTERED); send_robot_def(mzx_world, 0, LABEL_JUSTLOADED); change_board_set_values(mzx_world); change_board_load_assets(mzx_world); // Load the mod unless it's the mod from the title screen or *. strcpy(mzx_world->real_mod_playing, old_mod_playing); load_game_module(mzx_world, cur_board->mod_playing, true); sfx_clear_queue(); caption_set_world(mzx_world); return true; } if(was_faded) game->fade_in = false; return false; }
static char *boardmargin(void) { static char buf[STRLEN]; if (currbp->id) //% snprintf(buf, sizeof(buf), "讨论区 [%s]", currboard); snprintf(buf, sizeof(buf), "\xcc\xd6\xc2\xdb\xc7\xf8 [%s]", currboard); else { brc_init(currentuser.userid, DEFAULTBOARD); board_t board; get_board(DEFAULTBOARD, &board); change_board(&board); //% sprintf(buf, "讨论区 [%s]", currboard); sprintf(buf, "\xcc\xd6\xc2\xdb\xc7\xf8 [%s]", currboard); } return buf; }
void player_choice(char current_board[BOARD_SIZE][BOARD_SIZE], char future_board[BOARD_SIZE][BOARD_SIZE], char player) //function used to interpret the player's choice { int row = 0; int column = 0; int i = 0; int j = 0; switch(player) { case 'a': //adding a cell case 'A': printf("Inserting a cell.\n"); printf("Enter a row (any positive int < 40): "); scanf("%d", &row); if((row < 0) || (row > 40)) { printf("Invalid input.\n"); return; } printf("Enter a column (any positive int < 40): "); scanf("%d", &column); if((column < 0) || (column > 40)) { printf("Invalid input.\n"); return; } add_cell(future_board, row, column); //all edits are made to the future board change_board(current_board, future_board); //the boards a switched (current board is updated) printf("\033[2J\033[H"); print_board(current_board); //current board is printed break; case 'r': //removing a cell case 'R': printf("Removing a cell.\n"); printf("Enter a row (any positive int < 40): "); scanf("%d", &row); if((row < 0) || (row > 40)) { printf("Invalid input.\n"); return; } printf("Enter a column (any positive int < 40): "); scanf("%d", &column); if((column < 0) || (column > 40)) { printf("Invalid input.\n"); return; } delete_cell(future_board, row, column); change_board(current_board, future_board); printf("\033[2J\033[H"); print_board(current_board); break; case 'n': //applying the rules of the game case 'N': for(i = 0; i < BOARD_SIZE; i++) //the functions will read the current board but will apply the changes to the future board { for(j = 0; j < BOARD_SIZE; j++) { life_or_death(current_board, future_board, i, j, check_neighbors(current_board, i, j)); } } change_board(current_board, future_board); //boards are switched printf("\033[2J\033[H"); print_board(current_board); break; default: return; break; } return; }