[1+1=2]

OneAndOneIs2

« Linux & Zeno's ParadoxIt's December, then.. »

Sun, Dec 14, 2008

[Icon][Icon]Filling time

• Post categories: Omni, My Life, Programming

I've got too much free time on my hands lately, and I can only fill so much of it by reading library books.

So I dragged out my trusty K&R book and here we go again with playing around learning C.

I wanted to write something actually useful and complex to get back into the habit of writing code. So I'm writing a card game. Solitaire. The 'Klondike' version, I believe.

So far, it's going pretty well. It creates a deck of 52 cards, shuffles them, deals them, and prints an appropriate display:

        | * || _ |      | _ |   | _ |   | _ |   | _ |

                | 3D|   |   |   |   |   |   |   |   |   |   |   |   |
                        | 5C|   |   |   |   |   |   |   |   |   |   |
                                | 7D|   |   |   |   |   |   |   |   |
                                        | 9H|   |   |   |   |   |   |
                                                | 8H|   |   |   |   |
                                                        | 4C|   |   |
                                                                | KS|

That's the card stack top left, the aces stacks top right, and the tableau stacks beneath. The visible cards are the three of diamonds, five of clubs, seven of diamonds, nine of hearts, eight of hearts, four of clubs, and king of spades.

I'll use bash colour codes to make them red & black, and add the interface to actually PLAY the game later. But I'm quite impressed with how well it's gone so far, since I'd forgotten pretty much everything until I checked my notes this morning to remind me...

1 comment

titanium_geek
Comment from: titanium_geek [Visitor] · http://www.creativehedgehog.com
Hey, when you get the colour codes thing working (ahem, color, for more google results, sigh) can you please do a blog post about it- I would like to see an example of how it's done.
24/12/08 @ 00:44

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
This is a captcha-picture. It is used to prevent mass-access by robots.
Please enter the characters from the image above. (case insensitive)
 

[Links][icon] My links

[Icon][Icon] http://t.co/9VG31Knw
01/02/12

[Icon][Icon] Facebook Syndication Error
04/02/12

[Icon][Icon] I last listened to:
Johann Pachelbel - Canon in D major

[Icon][Icon] Most recent photo:
Submersible houseboat

[Icon][Icon]About Me

[Icon][Icon]About this blog

[Icon][Icon]My LQ profile

[Icon][Icon]My /. profile

[Icon][Icon]My Wishlist

[Icon]MyCommerce

[FSF Associate Member]


February 2012
Mon Tue Wed Thu Fri Sat Sun
 << <   > >>
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29        

Search

User tools

XML Feeds

eXTReMe Tracker

Valid XHTML 1.0 Transitional

Valid CSS!

[Valid RSS feed]

powered by b2evolution free blog software