Learn by Building Workshop Skills GitHub Türkçe Workshop › Klondike Solitaire › Step 26 of 40
A move counter What we are doing A good game shows how you are doing. We add moves, set it to 0 when dealing, and write Moves 0 at the top of the
table. Counting comes in the next step.
```js
let moves
moves = 0
ctx.fillStyle = 'white'
ctx.font = 'bold 15px sans-serif'
ctx.textAlign = 'left'
ctx.fillText('Moves ' + moves, LEFT, 24)
```What it means
moves is set to 0 in deal, so every new game starts from zero.
The text is drawn after the cards, at the top left; 'Moves ' + moves joins text and a number.
Your turn
Under let drag ... write let moves.
In deal, under piles.stock = deck, write moves = 0.
In draw, after the for loop's closing }, leave an empty line and write the four text lines.
Skills: Game states, Drawing on a canvas
← Tap to move Count the moves →
All steps The green table Draw one card The face of a card Red and black A deck of 52 Shuffle Piles in one object Deal the seven columns A place for every pile Put the piles on the table Fan out the columns Outlines for empty places Turn over a card Space turns a card Go through the stock again What is under the pointer? Hitting a card in a column Tap the stock Rule 1: building a column Rule 2: building a foundation Move cards by the rules Turn over the uncovered card Find where a card goes Pick up a card Tap to move A move counter Count the moves Where did you grab it? Follow the pointer Draw the held cards at the pointer Drop it where you want Drop a king into an empty column A clock Winning You won! A new game The best time Snapshots of the table Undo Build it yourself: finish by itself