The Essential Guide to HTML5

(Greg DeLong) #1

BLACKJACK


Code Explanation


} Closes the function


function swapindeck(j,k) { Helper function for the swapping


var hold = new MCard(deck[j].num,deck[j].
suit,deck[j].picture.src);


Saves the card in position j

deck[j] = deck[k]; Assigns the card in the k position to
the j position


deck[k] = hold; Assigns the hold to card in the k
position


} Closes the function


Closes the script element
Closes the head element
Opening tag to set the call to init
Press d for deal 1 more card,
h for hold, n for new game.

Header element containing
instructions

Canvas opener

Your browser doesn't support the HTML5
element canvas.


Warning to noncompliant browsers

Closes the element
Card images from [http://www.eludication](http://www.eludication)
.org/playingcards.html, Creative Common License
(http://creativecommons.org/
licenses/by-sa/2.5/).

Opens the footer element, which
contains credit for card images and
a link to the Creative Common
License

Fisher-Yates shuffle explained at
http://eli.thegreenplace.net
/2010/05/28/the-intuition-behind-
fisher-yates-shuffling


Adds the credit for article on the
shuffle algorithm

Closes the footer
Free download pdf