CHAPTER 10
Code Explanation
ctx.drawImage(playerhand[pi].picture,
playerxp,playeryp,cardw,cardh);
Draw on the canvas
playerxp = playerxp+30; Adjusts the horizontal pointer
pi++; Increases the count of cards to the
player
househand[hi] = dealfromdeck(2); Gets the first card for the dealer
ctx.drawImage(back,housexp,houseyp,cardw,cardh); Dr aws a cards back on the canvas
housexp = housexp+20; Adjusts the horizontal pointer
hi++; Increases the count of cards to the
dealer
playerhand[pi] = dealfromdeck(1); Deals a second card to the player
ctx.drawImage(playerhand[pi].picture,
playerxp,playeryp,cardw,cardh);
Draws on canvas
playerxp = playerxp+30; Adjusts the horizontal pointer
pi++; Increases the count of cards to the
player
househand[hi] = dealfromdeck(2); Deals a second card to the dealer
ctx.drawImage(househand[hi].picture,
housexp,houseyp,cardw,cardh);
Draws on the canvas
housexp = housexp+20; Adjusts the horizontal pointer
hi++; Increases the count of cards to the
house
} Close function
function deal() { Header for the function for dealing
through the game
playerhand[pi] = dealfromdeck(1); Deals a card to the player