jens@0: {\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf270 jens@0: {\fonttbl\f0\fnil\fcharset0 Verdana;} jens@0: {\colortbl;\red255\green255\blue255;} jens@0: \margl1440\margr1440\vieww13900\viewh17120\viewkind0 jens@0: \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural jens@0: jens@0: \f0\b\fs38 \cf0 GeekGameBoard jens@0: \b0\fs22 \ jens@0: \ jens@0: jens@0: \b by Jens Alfke jens@0: \b0 \ jens@0: \ jens@0: 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: \ jens@0: Some of the generally-useful Core Animation techniques illustrated are:\ jens@0: \'95 Hit testing\ jens@0: \'95 Dragging CALayers with the mouse\ jens@0: \'95 Loading images from files and setting them as layer contents\ jens@0: \'95 3D "card-flip" animations\ jens@0: \ jens@0: jens@0: \b\fs28 History jens@0: \b0 \ jens@0: jens@0: \fs22 \ jens@0: 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: \i unmodified jens@0: \i0 distribution.\ jens@0: \ jens@0: 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: \ jens@0: 1.0: Original Apple sample code release (12/19/2007)\ jens@0: 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: \ jens@0: jens@0: \b\fs28 Project Description\ jens@0: jens@0: \b0\fs22 \ jens@0: jens@0: \b Important Classes jens@0: \b0 \ jens@0: \ jens@0: A jens@0: \b Bit jens@0: \b0 is a moveable object in a game, either a jens@0: \b Card jens@0: \b0 or a jens@0: \b Piece jens@0: \b0 .\ jens@0: A jens@0: \b BitHolder jens@0: \b0 is a container for Bits; they can be dragged into and/or out of it. Typical BitHolders are jens@0: \b GridCell jens@0: \b0 s (the squares/hexes in a board), jens@0: \b Deck jens@0: \b0 s or jens@0: \b Stack jens@0: \b0 s of cards, and jens@0: \b Dispensers jens@0: \b0 (supplies of new pieces.)\ jens@0: A jens@0: \b Grid jens@0: \b0 is a regular arrangement of jens@0: \b GridCell jens@0: \b0 s; rectangular and hex grids are implemented.\ jens@0: jens@0: \b BoardView jens@0: \b0 is the NSView whose layer hosts all of the above. It also tracks mouse events so the user can drag Bits.\ jens@0: jens@0: \b Game jens@0: \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: jens@0: \b Player jens@0: \b0 is a passive object that represents one of the players in a Game.\ jens@0: \ jens@0: jens@0: \b Class Hierarchy jens@0: \b0 \ jens@0: \ jens@0: (Underlined classes are from external frameworks; italic classes are abstract.)\ jens@0: \ jens@0: \ul CALayer\ulnone \ jens@0: jens@0: \i Bit jens@0: \i0 \ jens@0: Card\ jens@0: PlayingCard\ jens@0: DraggedStack\ jens@0: Piece\ jens@0: DiscPiece\ jens@0: jens@0: \i BitHolder* jens@0: \i0 \ jens@0: jens@0: \i GridCell jens@0: \i0 \ jens@0: Hex\ jens@0: Square\ jens@0: GoSquare\ jens@0: Deck\ jens@0: Dispenser\ jens@0: Stack\ jens@0: jens@0: \i Grid jens@0: \i0 \ jens@0: HexGrid\ jens@0: RectGrid\ jens@0: \ jens@0: \ul NSView\ulnone \ jens@0: BoardView\ jens@0: \ jens@0: jens@0: \i \ul NSObject jens@0: \i0 \ulnone \ jens@0: jens@0: \i Game jens@0: \i0 \ jens@0: TicTacToeGame (etc...)\ jens@0: Player\ jens@0: \ jens@0: jens@0: \fs20 * BitHolder is actually both a protocol, and a class that implements the protocol. I've combined them here, for simplicity.\ jens@0: jens@0: \fs22 \ jens@0: \ jens@0: jens@0: \b\fs28 Related Information\ jens@0: jens@0: \b0\fs22 \ jens@0: \'95 {\field{\*\fldinst{HYPERLINK "http://developer.apple.com/samplecode/GeekGameBoard/"}}{\fldrslt Apple's original GeekGameBoard sample code}}\ jens@0: \'95 {\field{\*\fldinst{HYPERLINK "http://developer.apple.com/documentation/Cocoa/Conceptual/CoreAnimation_guide/index.html"}}{\fldrslt jens@0: \i Core Animation Programming Guide}}\ jens@0: jens@0: \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: \'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: \'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: \i0 \ jens@0: }