Drew or drew not, there is no try

Show Navigation

Apr
19

BlackJack

Posted on Thursday April 19, 2012 at 11:50pm in

This started as a small work project. I was told to learn the Ruby programming language, so I decided to make it a bit more fun and start a project. I started with programming a deck of cards. Simple cards with a suit and a rank, which you could build into a 52 card deck and then shuffle. After about an hour or so I had finished building a deck of cards that output to the terminal “ace of spades, queen of diamonds, 9 of clubs, etc…” Cool! Then, I decided to take it a step further and make a text-based version of BlackJack.

After a few days I had a working version of BlackJack that you could play through the terminal. You’d be given 2 cards and so would the dealer. Then the program would tell you your score and ask if you would like to hit. You could answer by typing Yes or No and hitting the enter button. Then it would either calculate the rest of the game and tell you who won if you hit stayed. If you asked to hit, it would give you a new card, tell you what it was and update your score. It worked pretty well.

Then I decided to get a little crazy with it. I wondered what it would take to make that program into a fully functional desktop application with graphics. I did a little bit of research into Ruby Shoes – a GUI designer for Ruby. I started playing around with it and started making the interface by hand. I was working on it for several hours a day. At this point, it had ceased to be a work project and more of a personal project. I wanted to get it working completely with several features which I had outlined as I got farther.

Well, over 2,000 lines of hand-typed code later – it all works! When I was finished I also went ahead and wrote the entire interface in Japanese as well – so you can play in either language. This is definitely my proudest programming accomplishment. I’ve never attempted something this big before, and I’m really happy with how it turned out. You can even download it on your computer and play it if you’d like! You also have to download Shoes (Shoes Packaging/Distribution is unfortunately not very good.) to run it, but it’s very simple. First, here are some screenshots of it running.

BlackJack
The welcome screen.

BlackJack
Settings menu. You can choose a different background or switch to Japanese.

BlackJack
The Japanese version.

BlackJack

BlackJack

BlackJack

BlackJack

BlackJack

Pretty cool right? You wanna play it, right!

Here’s how. Note: If you have a Mac I recommend using the Mac version. I developed it on Mac and it does run slightly better. You can also dynamically change wallpapers and your session will save after you close it. The Windows version still works just fine, but you can’t save your preferences.

How to Download
Windows
1. Download Shoes (click this link)
2. Launch Shoes and install it. It’s simple to install, just click Next until it finishes.
3. Download BlackJack
4. Double-click the rubyBlackJack file to start playing!

Mac OSX
1. Download Shoes (click this link)
2. Drag Shoes into your Applications Folder
3. Download BlackJack
4. Unzip BlackJack
5. Run Shoes.
6. Click “Open an App” and then navigate to the rubyBlackJack folder. Select rubyBlackJackGUI.rb to start playing!

Enjoy!

3 Comments

Leave a Comment

comments powered by Disqus