|
|||||||||||||||
Problem Set 2: Fifteen Assigned: Sunday February 12, 2012 Due: Wednesday February 22, 2012 Points: 10
FifteenIn this problem set, you will implement a 4x4 version of the simple tile game that your parents would give you to keep you quiet on long car trips. (If you held out for an iPod Touch or a PSP, you really missed out.) A simple version of the game is shown below.
The object of the game is to slide the tiles around until they are arranged in order. Your App doesn't have to keep track of the time (but see the extra credit below). This game can be implemented relatively easily as a Model View Controller App using the parts of the Core Graphics and Core Animations libraries that we have covered in class. You'll want to create a host or background UIView into which you will insert the tiles. This view should be an instance of a class that you create as a subclass of UIView. The tiles themselves should be UIViews centered at the appropriate positions in the host view. A touch event on a tile adjacent to the hole should cause the tile to slide to the hole. You may wish to use UIButtons to serve as tiles or you may define your own custom tiles as instances of a class that subclasses UIView. You will find the NSMutableArray class to be a useful structure for holding the 15 tiles that appear in the game. Where should each tile be centered? That isn't too hard to compute given the CGSize (i.e., height and width) of the host view and the CGSize of the tiles. You'll need to write all of the code necessary place the tiles randomly at app start time. Your app will need to detect that a player is attempting to move a tile with a touch event, your app will need need to determine whether or not the touched tile is adjacent to the hole and you'll need to reposition the tile (and the hole) as appropriate. When a tile has been successfully moved, your app should check to see if the tiles are ordered. Extra CreditI am leaving this open-ended to encourage creativity. But here are some ideas for extra credit:
|