CS193P – Assignment 2
Working so far from home would seem a chore to most people, but the hour train journey to and from my place of work each day gives me the ideal time to watch the iTunes U lectures on the iPad. Having completed assignment 1, with only a small number of technical hitches, mainly my messages array not displaying the historical messages for my slider correctly which had me scratching my head for bit, I’ve now moved onto assignment 2.
Paul covers more of the Foundation API’s in lectures 4 and 5 along with introspection and managing multiple MVC’s within a single application.
Assignment 2 allows you to use a lot of the code you’ve already written for assignment 1 whilst incorporating a new game called Set, which is accessed via a new tab bar controller. Set is a card game which uses 81 cards that differ in four ways, number, pattern, symbol and colour. The idea is to match a set of three cards, a set being that they all have one feature in common, or have all their features be different. This game is required to have the same functionality as the playing card game in that it must have a deal button, the usual game play messages, a flip count and a score.
There are also some optional requirements including adding a third tab to track game scores, adding yet another tab to let the player change the game settings, and adding icons into the UI tab bar.
As per the instructions, I changed the existing playing card game to only match on two cards and removed the segmented control. The new Set game starts with 24 cards randomly chosen from a deck of 81 Set cards.
My version of this assignment implements all required tasks including the addition of a UITabBar with tabs for each of the application screens; using NSAttributedString to draw the Set cards; and, providing flips, score, and game message labels as well as a “Deal” button in the Set game UI.
To implement the Set game, I used as much logic as possible from the existing Card Match implementation. To do this I had to amend CardMatchingGame to support both games without the class including game-specific play logic. Instead, I had each of the games Card class’ encapsulate it’s specific match rules. I moved some of the CardGameViewController code into a generic GameViewController and introduced a SetGameViewController to manage the UI specific to the set games view.
I also implemented the optional requirements of adding a scoreboard along with a settings screen with a number of sliders for adjusting various game specific settings.
As always my code for Assigment 2 can be found on GitHub: Assignment 2