Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Game::GameLoop()
- {
- //Game.turn non sdl2 redendering version use events to not delay rendering
- while((Game_Over == false)&&(quit == false))
- {
- GetGameGrid()->DisplayGrid();
- //turn 1 Player* pos1
- if (total_turns % 2 == 0)
- {
- int p1_turn = PlayerTurn(player_pos_1);
- if(p1_turn == 0) break;
- }
- //turn 2 Player* pos or AI - ai inherits player class
- else
- {
- int p2_turn = PlayerTurn(player_pos_2);
- if(p2_turn == 0) break;
- }
- //check for win if total_turns > 4
- //total_turns++; add to true case of if square available case
- if(total_turns > 4)
- {
- //scan through list of win cases for match. trigger Game_Over if match is found
- // if player 2 turn is next
- //check numbr matches other playrs turn messup earlier
- if(total_turns % 2 == 1)
- {
- // bool check if player1 won
- if(PlayerWin(player_pos_1))
- {
- std::cout << "Player 1 Wins!" << std::endl;
- Game_Over = true;
- }
- }
- else if(total_turns % 2 == 0)
- {
- // bool check if player2 won
- if(PlayerWin(player_pos_2))
- {
- std::cout << "Player 2 Wins!!" << std::endl;
- Game_Over = true;
- }
- }
- }
- if((total_turns > 8)&&(Game_Over == false)){
- //Draw case
- Game_Over = true;
- std::cout << "Draw!" << std::endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment