Cześć,ostatnio wzorując się na informacjach z pewnej książki napisałem grę ,,Rzut kostką,,
Jednak coś nie działa,
<html>
<head>
<title>Rzut pojedyńczą kością</title>
<script>
var cwidth = 400;
var cheight = 300;
var dicex = 50;
var dicey - 50;
var dicetidth = 100;
var dicehight = 100;
var dotared = 6;
var ctx;
function init() {
var ch = 1 + Math.floor(Math.random() * 6);
drawface(ch);
}
function drawface(n) {
ctx = document.getElementById('Canvas').
getContext('2d');
ctx.lineWidth = 5;
ctx.clearRect(dicex, dicey, dicewidth, dicehight);
ctx.strokeRect(dicex, dicey, dicewidth, dicehight);
ctx.fillStyle() = "#009966";
switch(n) {
case 1:
Draw1();
break;
case 2:
Draw2();
break;
case 3:
draw2();
draw1();
break;
case 4:
draw4();
break;
case 5:
draw4();
draw1();
break;
case 6:
draw4();
draw2mid();
break;
}
}
function draw1() {
var dotx;
var doty;
ctx.beginPath();
dotx = dicex + .5 * dicewidth;
doty = dicey + .5 * diceheight;
ctx.arc(dotx,doty, dotrad, 0, Math. PI * 2, true);
ctx.closePath();
ctx.fill();
}
function draw2() {
var dotx;
var doty;
ctx.beginPath();
dotx = dicex + 3 * dotrad;
doty = dicey + 3 * dotrad;
ctx.arc(dotx, doty, dotrad, 0, Math. PI * 2, true);
ctx.closePath();
ctx.fill();
}
function draw4() {
var dotx;
var doty;
ctx.beginPath();
dotx = dicex + 3 * dotrad;
doty = dicey + 3* dotrad;
ctx.arc(dotx, doty, dotrad, 0, Math. PI * 2, true);
dotx = dicex + dicewidth - 3 * dotrad;
doty = dicey + diceheight - 3 * dotrad;
ctx.arc(dotx, doty, dotrad, 0, Math. PI * 2, true);
ctx.closePath();
ctx.fill();
ctx.beginPath();
dotx = dicex + 3 * dotrad;
doty = dicey + diceheight - 3 * dotrad;
ctx.arc(dotx, doty, dotrad, 0, Math. PI * 2, true);
dotx = dicex + dicewidth - 3 * dotrad;
doty = dicey + 3 * dotrad;
ctx.arc(dotx, doty, dotrad, 0, Math. PI * 2, true);
ctx.closePath();
ctx.fill();
}
function draw2mid() {
var dotx;
var doty;
ctx.beginPath();
dotx = dicex + 3 * dotrad;
doty = dicey + .5 * dicehight;
ctx.arc(dotx, doty, dotrad, 0, Math. PI * 2, true);
dotx = dicex + dicewidth - 3 * dotrad;
doty = dicey + .5 * diceheight; //brak zmiany
ctx.arc(dotx, doty, dotrad, 0, Math. PI * 2, true);
ctx.closePath();
ctx.fill();
}
</script>
</head>
<body onload="init();">
<canvas id="canvas" width="400" height="300">
Twoja przeglądarka nie obsługuje elementu canvas stadardu HTML5.
</canvas>
</body>
</html>
Co źle zrobiłem?