Read Me.rtf
author Jens Alfke <jens@mooseyard.com>
Wed May 28 12:47:10 2008 -0700 (2008-05-28)
changeset 8 45c82a071aca
permissions -rw-r--r--
* Got it working with latest iPhone SDK.
* Fixed some text alignment issues that showed up on PlayingCards.
* Working on persistence and move-tracking for Game.
     1 {\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf270
     2 {\fonttbl\f0\fnil\fcharset0 Verdana;}
     3 {\colortbl;\red255\green255\blue255;}
     4 \margl1440\margr1440\vieww13900\viewh17120\viewkind0
     5 \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
     6 
     7 \f0\b\fs38 \cf0 GeekGameBoard
     8 \b0\fs22 \
     9 \
    10 
    11 \b by Jens Alfke
    12 \b0 \
    13 \
    14 GeekGameBoard is an example of using Core Animation to present the user interface of a board or card game. It implements a small framework for implementing such games, with domain-specific classes like "Grid" and "Piece", and examples of several game definitions built on top of the framework.\
    15 \
    16 Some of the generally-useful Core Animation techniques illustrated are:\
    17 \'95 Hit testing\
    18 \'95 Dragging CALayers with the mouse\
    19 \'95 Loading images from files and setting them as layer contents\
    20 \'95 3D "card-flip" animations\
    21 \
    22 
    23 \b\fs28 History
    24 \b0 \
    25 
    26 \fs22 \
    27 I wrote GeekGameBoard in 2007 while at Apple, which published it as sample code. Apple's sample code license allows unrestricted use of the source code, requiring only that you keep their copyright notice in an 
    28 \i unmodified
    29 \i0  distribution.\
    30 \
    31 I am no longer employed by Apple. To encourage further development of this framework, in March 2008 I created this open source project (under a BSD license) based on a slightly-evolved version of the published sample code.\
    32 \
    33 1.0: Original Apple sample code release (12/19/2007)\
    34 2.0: First open source release. (Major version number bumped to avoid conflict with any future Apple revisions.) No longer requires garbage collection. Fixed some memory leaks of CG objects. Fixed a bug when advancing to the 8th row in the Checkers game. (3/7/2008)\
    35 \
    36 
    37 \b\fs28 Project Description\
    38 
    39 \b0\fs22 \
    40 
    41 \b Important Classes
    42 \b0 \
    43 \
    44 A 
    45 \b Bit
    46 \b0  is a moveable object in a game, either a 
    47 \b Card
    48 \b0  or a 
    49 \b Piece
    50 \b0 .\
    51 A 
    52 \b BitHolder
    53 \b0  is a container for Bits; they can be dragged into and/or out of it. Typical BitHolders are 
    54 \b GridCell
    55 \b0 s (the squares/hexes in a board), 
    56 \b Deck
    57 \b0 s or 
    58 \b Stack
    59 \b0 s of cards, and 
    60 \b Dispensers
    61 \b0  (supplies of new pieces.)\
    62 A 
    63 \b Grid
    64 \b0  is a regular arrangement of 
    65 \b GridCell
    66 \b0 s; rectangular and hex grids are implemented.\
    67 
    68 \b BoardView
    69 \b0  is the NSView whose layer hosts all of the above. It also tracks mouse events so the user can drag Bits.\
    70 
    71 \b Game
    72 \b0  represents the rules of a particular game. It sets up the pieces/cards/grids that make up the game, decides which moves are legal, keeps track of whose turn it is, and decides when someone's won.\
    73 
    74 \b Player
    75 \b0  is a passive object that represents one of the players in a Game.\
    76 \
    77 
    78 \b Class Hierarchy
    79 \b0 \
    80 \
    81 (Underlined classes are from external frameworks; italic classes are abstract.)\
    82 \
    83 \ul CALayer\ulnone \
    84 	
    85 \i Bit
    86 \i0 \
    87 		Card\
    88 			PlayingCard\
    89 		DraggedStack\
    90 		Piece\
    91 			DiscPiece\
    92 	
    93 \i BitHolder*
    94 \i0 \
    95 		
    96 \i GridCell
    97 \i0 \
    98 			Hex\
    99 			Square\
   100 				GoSquare\
   101 		Deck\
   102 		Dispenser\
   103 		Stack\
   104 	
   105 \i Grid
   106 \i0 \
   107 		HexGrid\
   108 		RectGrid\
   109 \
   110 \ul NSView\ulnone \
   111 	BoardView\
   112 \
   113 
   114 \i \ul NSObject
   115 \i0 \ulnone \
   116 	
   117 \i Game
   118 \i0 \
   119 		TicTacToeGame (etc...)\
   120 	Player\
   121 \
   122 
   123 \fs20 * BitHolder is actually both a protocol, and a class that implements the protocol. I've combined them here, for simplicity.\
   124 
   125 \fs22 \
   126 \
   127 
   128 \b\fs28 Related Information\
   129 
   130 \b0\fs22 \
   131 \'95 {\field{\*\fldinst{HYPERLINK "http://developer.apple.com/samplecode/GeekGameBoard/"}}{\fldrslt Apple's original GeekGameBoard sample code}}\
   132 \'95 {\field{\*\fldinst{HYPERLINK "http://developer.apple.com/documentation/Cocoa/Conceptual/CoreAnimation_guide/index.html"}}{\fldrslt 
   133 \i Core Animation Programming Guide}}\
   134 
   135 \i \'95 {\field{\*\fldinst{HYPERLINK "http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_images/chapter_12_section_4.html"}}{\fldrslt Quartz 2D Programming Guide: Creating Images}}\
   136 \'95 {\field{\*\fldinst{HYPERLINK "http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_patterns/chapter_7_section_1.html"}}{\fldrslt Quartz 2D Programming Guide: Patterns}}\
   137 \'95 {\field{\*\fldinst{HYPERLINK "http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_paths/chapter_4_section_1.html"}}{\fldrslt Quartz 2D Programming Guide: Paths}}
   138 \i0 \
   139 }