HTML and CSS Reference
In-Depth Information
Code
Explanation
if (playertotal>housetotal) {
Performs a more specific
comparison
ctx.fillText("You won. ",30,100);
Displays the winner message
}
Closes the inner clause
else {
Begins else clause
ctx.fillText("TIE!",30,100);
Displays a message
}
Closes the else clause
}
Closes the outer clause
else
else
if (housetotal<=21) {
Checks if the dealer is under
ctx.fillText("You lost. ", 30,100);
Displays a message
}
Closes the clause
else {
Begins else clause
ctx.filltext("You won because
house went over.");
Displays a message (player under,
house over)
}
Closes the clause
}
Closes the function
function newgame() {
Header for the function for a new
game
ctx.clearRect(0,0,cwidth,cheight);
Clears the canvas
pi=0;
Resets the index for the player
hi=0;
Resets the index for the dealer
playerxp = 100;
Resets the horizontal position for
the first card of the player's hand
Search WWH ::




Custom Search