The Essential Guide to HTML5

(Greg DeLong) #1

CHAPTER 2


document.f.stage.value="Back to first
throw.";


Display Back to first throw

document.f.pv.value=" "; Clear the point value


firstturn = true; Reset firstturn so it is again
true


break; Exit the switch


case 7: If the sum is equal to 7


document.f.outcome.value="You lose!"; Display You lose!


document.f.stage.value="Back to first
throw.";


Display Back to first throw

document.f.pv.value=" "; Clear the point value


firstturn = true; Reset firstturn so it is again
true


} Close the switch


} Close the else clause


} Close the throwdice function


function drawface(n) {


ctx =
document.getElementById('canvas').getContext('2d');


ctx.lineWidth = 5;


ctx.clearRect(dx,dy,dicewidth,diceheight);


ctx.strokeRect(dx,dy,dicewidth,diceheight)


var dotx;


var doty;


ctx.fillStyle = "#009966";

Free download pdf