ActionScript 3 Solitaire - Klondike

| 12 Comments | No TrackBacks

Here's a little game I've been working on - Solitaire (Klondike) - written using an ActionScript3-only project in FlexBuilder 2.

ActionScript 3 Solitaire (requires Flash Player 8.5 to view).

I'm not entirely sure what I want to do with this code yet. I think I'll be placing it inside of IFBIN but it doesn't really belong in Flex By Example since it's not a Flex project. Additionally, it's not really a Flash project because Flash doesn't have ActionScript 3 support yet so at the moment it doesn't really belong in Flash By Example. I think what I might do is create a Flex 2 shell for the game with a classic menubar and an options panel to configure scoring, deal 1 vs. deal 3 and the card/deck skin, and then add the whole thing into Flex By Example.

This is a great example to use as a starting point for other card games going forward. I've created a generic card engine that is completely skinnable and can easily be extended to create other games (such as FreeCell, Poker, etc). The game features a modular Object-Oriented architecture, so the core card engine can easily be dropped into a game and function without issue. Creating FreeCell from this example is just a matter of changing the game rules since everything else can be re-used.

This is also a good example of using the new DisplayList API. Whenever you drag some cards around, there's no need to worry about depth management or attaching and removing MovieClips to achieve the effect (things we had to worry about with ActionScript 2). Instead, just re-parent the cards and magically they're on top of everything. When the cards are dropped, re-parent the cards again, and magically they're attached elsewhere. I'm really diggin' the new DisplayList.

There are still some things not done - for instance, there's no scoring, and there's no super-cool end game animation sequence (or even a message that tells you you win). However, the game is fully playable, and capable of wasting hours of your life at a time if you let it.

Enjoy!

No TrackBacks

TrackBack URL: http://www.darronschall.com/mt/mt-tb.cgi/79

12 Comments

Leave a comment

Flex.org - The Directory for Flex

Archives