This is a screenshot of the start screen for my poker game. Displayed are the five cards in each players hand, they begin the game facing down as the game has not begun. Text on the screen describes how the player starts the game.
Here is a screenshot of the revealing stage of my poker game. Both players hand are shown with all five cards faced down, this is so that neither player knows what cards each player has before the game has begun. The game is started when player one presses the "R" key to reveal their hand. All of the cards in player ones hand are flipped over for both players to see.
Here is a screenshot of player ones first turn. The player has three choices swap all of their cards, keep their hand or swap a card for another. If the later is chosen the player may repeat this up to five times. When this has been done the game will proceed to player twos turn.
This is a screenshot of the beginning of player twos turn. This follows the same format as player ones turn, however everything affects their hand rather than player ones hand. When player two has finished their turn the game will proceed onto the "Determine Winner" stage.
This is the "Determine Winner" game state. In this game state the program will go through each of the winning conditions and award the players points equal to the value of the hand that they have. If both players have the "Highest Card" hand then the player with the highest value card will be the winner, otherwise the player with the highest hand value will be the winner. If both players have the same value hand which isn't the "Highest Card" hand then the game is a draw. When the game has been complete the game will loop back and start again.
Here is a screenshot of the winning screen. Depending on who won the game, the program will display text saying the outcome of the game. Text is also displayed onto the screen to tell the players how to play another game.
Here is a screenshot of how to declare messages in my game. Each message is given a string value which is the text that is printed. All of the messages are printed onto the same location of the screen.
The “Initialise” game state is the first game state to be used when starting a game. It clears all other messages off the screen and prints the message “StartScreenMessage” onto the screen. The game state is then changed to the “StartScreen” game state.
The “StartScreen” game state is used as the start screen to any game. The game will stay in the “StartScreen” game state until the player presses the “s” key on the keyboard. This will then clear all messages off the screen and will deal 5 cards to each player. The message “Reveal” The game state is then changed to “Revealing”.
The “Revealing” game state is the first game state of player ones turn. By pressing the “r” key all messages are removed from the screen and all of player ones cards are turned face up, the message “ChangeCard” is then printed onto the screen. The game state is then changed to “CardChange1”.
“CardChange1” is the gamestates that allows player one to swap or keep their cards. If the “s” key is pressed then the player keeps all of their cards and the variable “iAction1” is increased to 5. If the “c” key is pressed the all of the players cards are discarded and 5 more cards are dealt to the player, this can only be done once. To change individual cards the player must press the button that represents the card they wish to change (1,2,3,4 or 5) this card is then discarded and a new card is dealt to the player, every time this is done the variable “iAction1” is incremented. When the variable “iAction1” is higher than 4 all messages are cleared from the board, the message “PlayerTwoMsg” is printed to the screen and the game state is changed to “PlayerTwo”.
This game state is player twos equivalent of the “StartScreen” game state. Player two then proceeds to have a reveal and change card game state as player one did, however everything which they do affect player twos cards rather than player ones cards.
This game state assigns the scores of every card in the players hand to a variable equivalent, this includes the suit and the rank of the card. The game state then checks if either of the cards is an ace, if so an additional variable is assigned the value 1 so it is easier to calculate straights. The program then goes through every possible hand to check if player one has got any, an integer is the assigned to the variable “iPlayer1Score” for the highest value. This is done by overwriting the variable “iPlayerScore1” every time the player has a hand that matches a rank, the program checks the lowest hand ranking first and the highest card ranking last. When the program has checked through every possible hand combination the game state is changed to “P2AssignScore”.
The “Compare” game state is used to compare the two variables “iPlayer1Score” and “iPlayer2Score”. If “iPlayer1Score” is higher than “iPlayer2Score” then player one has won, if “iPlayer2Score” is higher than “iPlayer1Score” then player two has won. If neither have higher variables are higher and both variables have the value of 1 the game checks to see which has the highest card in their hand. If both players have the same highest card or have the same points value then the game is a draw. If player one wins the message “P1Winning” is printed onto the screen, if player two wins the message “P2Winning” is printed onto the screen and if the game is a draw the message “Draw” is printed onto the screen. The game state is then changed to “Winning”.
This game state is the final games state of the game, it displays who the winner of the game was and allows the players to play the game again. If the “Enter” key is pressed then all of the variables used in the game are reset, all messages are removed from the screen and the game state is change to “Initialise”. If i was going to repeat this project I would make calculating the value of a hand more efficient. this would be achieved by creating an array of fourteen values. Each of the values in this array would represent each different card value in a deck. They would then be incremented if a card in the players hand had the same value as the array. For example if the player had a five and two eights in their hand the fifth value in the array would be incremented once and the eighth value in the array would be incremented twice. When looking at what value the hand had the program would see that the eighth value was equal to two meaning that the player had a pair of eights.
gLike
Poker - Card Game - C++

This is a card game that I created in C++ using SFML and a card game SDK. The game is a basic version of poker.

The goal of the game is to get a better hand than the opponent, this will be determined at the end of the game.

When the game has been completed the game will return to the first stage and the game will continue as a loop.

The main mechanic for this game is the use of game states. The game states used in the game are as follows: Initialise, StartScreen, Revealing, CardChange1, PlayerTwo, Revealing2, CardChange2, P1AssignScore, P2AssignScore, Compare, Winning. All of these game states are required to do different task, although some of the game states are similar they all perform unique tasks.

Gethin Watkins
Student Leicester, United Kingdom