static gboolean game_handle_io (GGZMod * mod) { int op = -1; fd = ggzmod_get_server_fd (mod); // Read the fd if (ggz_read_int (fd, &op) < 0) { ggz_error_msg ("Couldn't read the game fd"); return FALSE; } switch (op) { case GN_MSG_SEAT: get_seat (); break; case GN_MSG_PLAYERS: get_players (); break; case GN_MSG_START: gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), MAIN_PAGE); new_game (); break; case GN_MSG_SYNC: get_sync (); break; case GN_MSG_MOVE: get_move (); break; case GN_MSG_SETTINGS: get_settings (); break; case GN_MSG_BONI: get_boni (); break; case GN_MSG_NOBONI: get_noboni (); break; default: ggz_error_msg ("Incorrect opcode %d \n", op); break; } return TRUE; }
void ScreenManager::draw_player_pos(DrawingContext& context) { if (auto session = GameSession::current()) { auto sector = session->get_current_sector(); if (sector == nullptr) return; auto pos = sector->get_players()[0]->get_pos(); auto pos_text = "X:" + std::to_string(int(pos.x)) + " Y:" + std::to_string(int(pos.y)); context.color().draw_text( Resources::small_font, pos_text, Vector(static_cast<float>(context.get_width()) - Resources::small_font->get_text_width("99999x99999") - BORDER_X, BORDER_Y + 40.0f), ALIGN_LEFT, LAYER_HUD); } }
main() { register BOARD *brd; /* The main Othello Board descriptor. */ register int stalemate; /* TRUE if no legal moves for anyone. */ /* Create the main Othello Board. */ if ( (brd = brdcreat()) != NULL ) { if ( get_players ( brd ) ) /* Initialise Players */ { setup_board ( brd ); /* Set up Othello Board. */ show_board ( brd ); /* Display Othello Board. */ }; }; /* Main loop - repeats until end_othello takes a non-zero value */ while ( !end_othello ) { /* Handle a single turn for a computer or human Player. */ if ( brd->player->level >= 0 ) { /* Handle the computer-controlled Player's turn - note that * do_computer() now returns TRUE if the computer could * find no legal moves for itself _or_ for the human player. * * This facility used to be in the function game_over(), but * has been shifted into do_computer() to speed up execution. */ stalemate = do_computer ( brd ); } else { do_human ( brd ); /* Handle a human Player's turn */ stalemate = FALSE; }; show_board ( brd ); /* Redisplay Othello Board. */ if ( game_over ( brd, stalemate ) ) /* If Game Over found...*/ { setup_board ( brd ); /* ...Set up Board for new game */ show_board ( brd ); /* Redisplay Othello Board. */ }; }; /* Display the error code, waiting for a key press after it is displayed. */ pause ( errors[end_othello - 1] ); while ( brd != NULL ) /* Free Othello Board descriptor memory block. */ { if ( brd->board != NULL ) free ( brd->board ); if ( brd->player != NULL ) { if ( brd->player < brd->player->opponent ) free ( brd->player ); else free ( brd->player->opponent ); }; free ( brd ); brd = brd->nxtbrd; }; };