For the first project I'm choosing to share I thought I would go back to a recent assignment that I submitted as part of my course. I won't go into detail on the code itself here as that is included in the GitHub repository linked at the end.
The Brief
The brief for this assignment was to design and develop a program for a simple card game. While we were given a certain degree of freedom to create a card game of our choice the following features were requested fromt he program we submitted:
- A deck of cards being able to be dealt and shuffled.
- A way to see the hands of all players.
- A formula for determining the winner.
Chosen Game
I decided that for my application I wanted to create a Higher or Lower
card game, based on two factors with the first being to differentiate
myself from my fellow students who were doing Blackjack themed games and
the second being my childhood memories of being at my grandparents with
the television showing Play Your Cards Right. The object of the game is to guess whether the next card you are dealt will be higher or lower than your currently held card.
Basic Code
During the teaching of the module we we were given a basic tutorial document that provided us with the code necessary to import the card images and shuffle them.
Main Program
The first thing I wanted to include was an interactive main menu that linked to a rules section and also had the card values shown for the players. These backgrounds and buttons were designed in Photoshop.
Next I needed the actual game itself to include a display that showed both players cards, had buttons to make their guesses, kept score of correct guesses, displayed the currently active player, had a tally of round winners and also allowed for the option to return to the menu or exit the program entirely.
Finally I needed to ensure that the game logic I had programmed matched the intended ruleset of the game. For this I needed the game to replace card values after every guess so that the cards being used for comparisons were accurate and guesses were therefore registered correctly. I also needed correct guesses to add one to a player's score. Finally, I wanted the currently active player to change after thirteen cards were in their hand.
I now needed to repeat this for the second player but at the end of their turn the game needed to pause, compare the correct guesses and add one to the total score on the right side of the screen. I wanted the game state to be reset so that each player had a single card each and their scores set to zero. I needed the overall scores to be remembered however so that scenarios such as the best of three could be played if wished.
Conclusion
I was very satisfied with how the final project turned out and I was especially pleased with getting the logic of the game working considering the problems I had with it during the design. For example, at one point I had an issue where seemingly at random players were getting more than thirteen cards and I didn't know why. It turned out that while I had the player card count set to increase by one when the next card was higher or lower than the current card I had not added this logic for if the next card was identical so the card count would remain the same and the player would get an extra card for each time this happened.
If I was to make another attempt at this I would add a more prominent display of the currently active player and also display a message temporarily on the screen to indicate when a player's turn was over. I could also have added a count somewhere to let players know how many guesses they have left in their turn.
The code for this project can be seen here.