/** * \brief All players are colliding with the item. * \param p1 The first player. * \param p2 The second player. */ void ptb::link_on_players::on_all_players ( const player_proxy& p1, const player_proxy& p2 ) { player* player_1(p1.get_player_instance()); player* player_2(p2.get_player_instance()); // all players does not mean two players in single player game. if ( (player_1 != NULL) && (player_2 != NULL) ) { if ( !player_1->is_linked_to(*player_2) ) { bear::universe::link* link ( new bear::universe::link ( *player_1, *player_2, m_strength, m_minimal_length, m_maximal_length ) ); if (m_link_visual != NULL) { bear::base_link_visual* vis(m_link_visual->clone()); vis->set_items(player_1, player_2, link->get_id()); new_item(*vis); } } } } // link_on_players::on_all_players()
void main_menu(){ int choice; system("cls"); system("COLOR 1C"); //selecting color of background and text to be displayed printf("\n-----START MENU-----"); printf("\n1 : Play with X"); printf("\n2 : Play with O"); printf("\n3 : Exit"); printf("\nEnter your choice:> "); scanf("%d",&choice); turn = 1; switch (choice){ case 1: player = 1; computer = 0; player_1(); break; case 2: player = 0; computer = 1; begin_game(); break; case 3: exit(1); default: main_menu(); } }
void player_1(){ int pos; tie_checker(); draw_board(); gotoxy(30,18); printf("Your Turn :> "); scanf("%d",&pos); if(panel[pos] != 2) player_1(); if(pos == posswin(player)){ go(pos); draw_board(); gotoxy(30,20); system("cls"); //clearing screen to displa result system("COLOR 1A"); //selecting color of panel showing result printf("\t\t\t\tPlayer Wins\n\t\t\t -----GAME OVER-----"); getch(); exit(0); } go(pos); draw_board(); begin_game(); }
void begin_game(){ if(posswin(computer)){ go(posswin(computer)); flag = 1; } else if(posswin(player)) go(posswin(player)); else if(make2()) go(make2()); else go(make4()); draw_board(); if(flag){ gotoxy(30,20); system("cls"); //clearing screen to displa result system("COLOR 4F"); //selecting color of panel showing result printf("\t\t\t Computer wins\n\t\t\t -----GAME OVER-----"); getch(); } else player_1(); }
void ResourceCache::LoadPlayerResources(const TiXmlHandle& hndl) { PlayerResource player_1(LoadPlayer(PlayerType::Player_1, "Player_1", hndl)); PlayerResource player_2(LoadPlayer(PlayerType::Player_2, "Player_2", hndl)); PlayerResource player_3(LoadPlayer(PlayerType::Player_3, "Player_3", hndl)); PlayerResource player_4(LoadPlayer(PlayerType::Player_4, "Player_4", hndl)); mPlayerRes.insert({ player_1.GetType(), player_1 }); mPlayerRes.insert({ player_2.GetType(), player_2 }); mPlayerRes.insert({ player_3.GetType(), player_3 }); mPlayerRes.insert({ player_4.GetType(), player_4 }); }