BLACKJACK
Code Explanation
ctx.drawImage(playerhand[pi].picture,
playerxp,playeryp,cardw,cardh);
Draws on the canvas
playerxp = playerxp+30; Adjust the horizontal pointer
pi++; Increases the count of cards to the
player
if (more_to_house()) { if function to say there should be
more cards for the dealer
househand[hi] = dealfromdeck(2); Deals a card to the house
ctx.drawImage(househand[hi].picture,
housexp,houseyp,cardw,cardh);
Draws a card on canvas
housexp = housexp+20; Adjusts the horizontal pointer
hi++; Increases the count of cards to the
dealer
} Closes the if-true clause
} Close function
function more_to_house(){ Header for the function determining
the dealers moves
var ac = 0; Variable to hold the count of aces
var i; Variable for iteration
var sumup = 0; Initializes the variable for the sum
for (i=0;i<hi;i++) { Iterates over all the cards
sumup += househand[i].value; Adds up value of cards in the
dealers hand
if (househand[i].value==1) {ac++;} Keeps track of the number of aces
} Closes the for loop