Read Me.rtf
author Jens Alfke <jens@mooseyard.com>
Mon Mar 10 17:32:04 2008 -0700 (2008-03-10)
changeset 2 7b0441db81e5
permissions -rw-r--r--
Oops, needed to fix an #include
jens@0
     1
{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf270
jens@0
     2
{\fonttbl\f0\fnil\fcharset0 Verdana;}
jens@0
     3
{\colortbl;\red255\green255\blue255;}
jens@0
     4
\margl1440\margr1440\vieww13900\viewh17120\viewkind0
jens@0
     5
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural
jens@0
     6
jens@0
     7
\f0\b\fs38 \cf0 GeekGameBoard
jens@0
     8
\b0\fs22 \
jens@0
     9
\
jens@0
    10
jens@0
    11
\b by Jens Alfke
jens@0
    12
\b0 \
jens@0
    13
\
jens@0
    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.\
jens@0
    15
\
jens@0
    16
Some of the generally-useful Core Animation techniques illustrated are:\
jens@0
    17
\'95 Hit testing\
jens@0
    18
\'95 Dragging CALayers with the mouse\
jens@0
    19
\'95 Loading images from files and setting them as layer contents\
jens@0
    20
\'95 3D "card-flip" animations\
jens@0
    21
\
jens@0
    22
jens@0
    23
\b\fs28 History
jens@0
    24
\b0 \
jens@0
    25
jens@0
    26
\fs22 \
jens@0
    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 
jens@0
    28
\i unmodified
jens@0
    29
\i0  distribution.\
jens@0
    30
\
jens@0
    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.\
jens@0
    32
\
jens@0
    33
1.0: Original Apple sample code release (12/19/2007)\
jens@0
    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)\
jens@0
    35
\
jens@0
    36
jens@0
    37
\b\fs28 Project Description\
jens@0
    38
jens@0
    39
\b0\fs22 \
jens@0
    40
jens@0
    41
\b Important Classes
jens@0
    42
\b0 \
jens@0
    43
\
jens@0
    44
A 
jens@0
    45
\b Bit
jens@0
    46
\b0  is a moveable object in a game, either a 
jens@0
    47
\b Card
jens@0
    48
\b0  or a 
jens@0
    49
\b Piece
jens@0
    50
\b0 .\
jens@0
    51
A 
jens@0
    52
\b BitHolder
jens@0
    53
\b0  is a container for Bits; they can be dragged into and/or out of it. Typical BitHolders are 
jens@0
    54
\b GridCell
jens@0
    55
\b0 s (the squares/hexes in a board), 
jens@0
    56
\b Deck
jens@0
    57
\b0 s or 
jens@0
    58
\b Stack
jens@0
    59
\b0 s of cards, and 
jens@0
    60
\b Dispensers
jens@0
    61
\b0  (supplies of new pieces.)\
jens@0
    62
A 
jens@0
    63
\b Grid
jens@0
    64
\b0  is a regular arrangement of 
jens@0
    65
\b GridCell
jens@0
    66
\b0 s; rectangular and hex grids are implemented.\
jens@0
    67
jens@0
    68
\b BoardView
jens@0
    69
\b0  is the NSView whose layer hosts all of the above. It also tracks mouse events so the user can drag Bits.\
jens@0
    70
jens@0
    71
\b Game
jens@0
    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.\
jens@0
    73
jens@0
    74
\b Player
jens@0
    75
\b0  is a passive object that represents one of the players in a Game.\
jens@0
    76
\
jens@0
    77
jens@0
    78
\b Class Hierarchy
jens@0
    79
\b0 \
jens@0
    80
\
jens@0
    81
(Underlined classes are from external frameworks; italic classes are abstract.)\
jens@0
    82
\
jens@0
    83
\ul CALayer\ulnone \
jens@0
    84
	
jens@0
    85
\i Bit
jens@0
    86
\i0 \
jens@0
    87
		Card\
jens@0
    88
			PlayingCard\
jens@0
    89
		DraggedStack\
jens@0
    90
		Piece\
jens@0
    91
			DiscPiece\
jens@0
    92
	
jens@0
    93
\i BitHolder*
jens@0
    94
\i0 \
jens@0
    95
		
jens@0
    96
\i GridCell
jens@0
    97
\i0 \
jens@0
    98
			Hex\
jens@0
    99
			Square\
jens@0
   100
				GoSquare\
jens@0
   101
		Deck\
jens@0
   102
		Dispenser\
jens@0
   103
		Stack\
jens@0
   104
	
jens@0
   105
\i Grid
jens@0
   106
\i0 \
jens@0
   107
		HexGrid\
jens@0
   108
		RectGrid\
jens@0
   109
\
jens@0
   110
\ul NSView\ulnone \
jens@0
   111
	BoardView\
jens@0
   112
\
jens@0
   113
jens@0
   114
\i \ul NSObject
jens@0
   115
\i0 \ulnone \
jens@0
   116
	
jens@0
   117
\i Game
jens@0
   118
\i0 \
jens@0
   119
		TicTacToeGame (etc...)\
jens@0
   120
	Player\
jens@0
   121
\
jens@0
   122
jens@0
   123
\fs20 * BitHolder is actually both a protocol, and a class that implements the protocol. I've combined them here, for simplicity.\
jens@0
   124
jens@0
   125
\fs22 \
jens@0
   126
\
jens@0
   127
jens@0
   128
\b\fs28 Related Information\
jens@0
   129
jens@0
   130
\b0\fs22 \
jens@0
   131
\'95 {\field{\*\fldinst{HYPERLINK "http://developer.apple.com/samplecode/GeekGameBoard/"}}{\fldrslt Apple's original GeekGameBoard sample code}}\
jens@0
   132
\'95 {\field{\*\fldinst{HYPERLINK "http://developer.apple.com/documentation/Cocoa/Conceptual/CoreAnimation_guide/index.html"}}{\fldrslt 
jens@0
   133
\i Core Animation Programming Guide}}\
jens@0
   134
jens@0
   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}}\
jens@0
   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}}\
jens@0
   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}}
jens@0
   138
\i0 \
jens@0
   139
}