Let’s Make Solitaire in Unity Part 1: Set Up and Shuffle

In part one we take a quick look at the background, confirm the rules of Klondike Solitaire and start to set up the scene. We acquire the required assets and start on the first scripts to generate a deck of cards and shuffle them.

Play Solitaire in your browser

Download the Unity Package

Royalty free assets:

Card sprites available at Opengameart.org

Card back sprite from Pixabay.com

Fisher Yates Shuffle extension from Stack Overflow.



Part 1: Set Up and Shuffle

Part 2: Dealing to the Tableau

Part 3: Dealing from the Stock

Part 4: Interactive Card Management and Rules for Stacking

Part 5: Building Foundations and Playing Solitaire

Part 6: Double Clicks, Reset and Winning the Game


Solitaire is a classic card game from the 1700s that has seen its fair share of video game adaptations. It first appeared as an 8 bit Atari game and a version was included on every edition of Microsoft Windows up until Windows seven, if you google solitaire, a playable game is embedded within the search results page. With so many different versions, several coding solutions are available so as part of this challenge I am going to use none of them. This means that the implementation we create in this series will be a unique version that plays specifically on functionality provided by the Unity game engine, but it also means that it will not be the cleanest or most concise implementation possible.

I did not set out to make the most cohesive, refactored or neatest version of solitaire but instead I treated this project like a game jam. Whilst I did have a loose plan of what I wanted to create, I did not spend much time planning out the exact design of the software so from a software engineering perspective it is a bit of a mess however, Solitaire is not the most complicated game, so I have confidence that we will get a half decent version that we can make together and hopefully learn something along the way. A word of warning, I will explain what I am doing as we go along, but we will be doing a fair number of juggling arrays and lists so having a basic understanding of them is probably a prerequisite to your enjoyment of this series. Additionally, I’d recommend that you have taken the time to do some basic unity tutorials as, although this is not tricky stuff, it is not aimed at an absolute novice either.


Before we start building Solitaire in Unity we need to be aware of the basic rules of the game. The version we are building is the basic Klondike version. It is played with a standard 52 card deck which is shuffled and then partially dealt into seven piles from left to right. Each pile contains one more card than the last and only the final card in each pile is dealt face up. The remainder of the deck is placed face down at the top of the play field. The aim of the game is to move all the cards from the seven spaces in the bottom row to the four spaces in the top row. Cards on the bottom row may be sequentially built down by alternate colours from king to ace, and the top row is built up by suit Ace to king. Only Kings can be moved to empty spaces on the bottom row, only Aces can be moved to empty spaces on the top row. Stacks of cards on the bottom row can carry the cards beneath them when they are moved to another space on the bottom row. If the back of a card is exposed on the bottom row, then that card may be flipped over to enter play.
The remaining cards from the deck are made available to the player in different ways depending on the version you are playing but we will start with the most popular and maybe add additional functionality later. In this version the player may deal three cards at a time from the top deck face up but can only access the last card to use in the game. We will place no limit on the number of re-deals.
Additionally, if a player double clicks a card and it is eligible to enter the top row, it should automatically fly up there.

Facebook Comments

Leave a Reply

Your email address will not be published. Required fields are marked *