Dec 20 2007

GeekGameBoard

Santa has an early Xmas present for all you good Leopard programmers: GeekGameBoard, a new piece of sample code by the anonymous engineer elves at Apple.

[Update: GeekGameBoard is now an open-source project hosted at bitbucket.org.]

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.
Some of the generally-useful Core Animation techniques illustrated are:
• Hit testing
• Dragging CALayers with the mouse
• Loading images from files and setting them as layer contents
• 3D “card-flip” animations

Framework classes include Bit, Piece, PlayingCard, HexGrid and more. It comes with sample games from Klondike solitaire to Checkers and even Tic-Tac-Toe. It’s all ready for you to add AI, network play, new game definitions…

Klondike

Hexchequer

PS: Icon websites like IconFactory, InterfaceLift and DeviantArt are great places to get artwork for game pieces. (My personal favorite game pieces are Ginko’s Icons, shown on the right.) Just be aware that most icons, even if freeware, require you to get the copyright holder’s permission for anything other than personal use.


5 Responses to “GeekGameBoard”

  • jmissig (LJ) Says:

    I love those anonymous elves. Can’t wait to look at some of the Core Animation hit testing and the like.

  • Brian Christensen Says:

    This is pretty neat. Thanks for linking to it.

  • aegidian (LJ) Says:

    Cool, I’ll have to look into this garbage-collection business though - so used to doing refcounting !

  • Jens Alfke Says:

    @aegidian — It’s just like doing refcounting, except that every time you were going to type “[foo retain]” or “[foo release]”, you eat a piece of candy instead. It’s delicious, if somewhat fattening.

  • HLC Says:

    This is a great learning tool for those of us just getting started. I have seen you use some things that I am not really familiar with. Would it be appropriate to use this forum to ask some basic Objective C questions related specifically to your code?

    Many thanks again,
    HLC