<!doctype html>
< 青岛职业学院html lang=”en”>
<head>
<title>throwing 1</title>
<script type=”text/javascript”>
var cwidth = 400;
var cheight = 300;
var dicex = 50;
var dicey = 50;
var dicewidth = 100;
var diceheight = 100;
var dotrad = 6;
var ctx;
var dx;
var dy;
var firstturn = true;
var point;
function throwdice(){
var sum;
var ch = 1+math.floor(math.random()*6);
sum = ch;
dx = dicex;
dy = dicey;
drawface(ch);
dx = dicex + 150;
ch = 1 + math.floor(math.random()*6);
sum += ch;
drawface(ch);
if(firstturn){
switch(sum){
ca 7:
ca 11:
document.f.out新兴行业come.value=”you win!”;
break;
ca 2:
ca 3:
ca 12:
document.f.outcome.value=”you lo!味捷外卖221;;
break;
default:
point = sum;
document.f.pv.value = point;
firstturn = fal;
document.f.stage.value = “need follow-up throw.”;
document.f.outcome.value = “”;
}
}el{
switch(sum){
ca point:
document.f.outcome.value = “you win!”;
document.f.stage.value = “back to first throw.”;
document.f.pv.value = “”;
firstturn = true;
break;
ca 7:
document.f.outcome.value = “you lo!”;
document.f.stage.value = “back to first throw.”;
document.f.pv.value = “”;
firstturn = true;
}
}
}
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’;
switch(n){
ca 1:
draw1();
break;
ca 2:
draw2();
break;
ca 3:
draw2();
张诗诗draw1();
break;
ca 4:
draw4();
break;
ca 5:
draw4();
draw1();
break;
ca 6:
draw4();
draw2mid();
break;
}
}
function draw1(){
var dotx;
var doty;
ctx.beginpath();
dotx = dx + 0.5*dicewidth;
doty = dy + 0.5*diceheight;
ctx.arc(dotx,doty,dotrad,0,math.pi*2,true);
ctx.clopath();
ctx.fill()
}
function draw2(){
var dotx;
var doty;
ctx.beginpath();
dotx = dx + 3*dotrad;
doty = dy + 3*dotrad;
ctx.arc(dotx,doty,dotrad,0,math.pi*2,true);
dotx = dx + dicewidth – 3*dotrad;
doty = dy + diceheight – 3*dotrad;
ctx.arc(dotx,doty,dotrad,0,math.pi*2,true);
ctx.clopath();
ctx.fi家人团聚的幸福的句子ll();
}
function draw4(){
var dotx;
var doty;
ctx.beginpath();
dotx = dx + 3*dotrad;
doty = dy + 3*dotrad;
ctx.arc(dotx,doty,dotrad,0,math.pi*2,true);
dotx = dx + dicewidth -3*dotrad;
doty = dy + dicewidth -3*dotrad;
ctx.arc(dotx,doty,dotrad,0,math.pi*2,true);
ctx.clopath();www.2cto.com
ctx.fill();
ctx.beginpath();
dotx = dx + 3*dotrad;
doty = dy + diceheight – 3*dotrad;
ctx.arc(dotx,doty,dotrad,0,math.pi*2,true);
dotx = dx + dicewidth – 3*dotrad;
doty = dy + 3*dotrad;
ctx.arc(dotx,doty,dotrad,0,math.pi*2,true);
ctx.clopath();
ctx.fill();
}
function draw2mid(){
var dotx;
var doty;
ctx.beginpath();
dotx = dx + 3*dotrad;
doty = dy + 0.5*diceheight;
ctx.arc(dotx,doty,dotrad,0,math.pi*2,true);
dotx = dx + dicewidth – 3*dotrad;
doty = dy + 0.5*diceheight;
ctx.arc(dotx,doty,dotrad,0,math.pi*2,true);
ctx.clopath();
ctx.fill();
}
</script>
</head>
<body>
<canvas id=”canvas” width=”400″ height=”300″>
不支持html5
</canvas>
<br/>
<button>throw dice</button>
<form name=”f”>
stage:<input name=”stage” value=”first throw” /><br/>
point:<input name=”pv” value=”” /><br/>
outcome:<input name=”outcome” value=”” />
</form>
</body>
</html>
本文发布于:2023-04-03 02:08:23,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/f1b1d358331fb4a765bed48f1002c01e.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:html5游戏掷骰子源码.doc
本文 PDF 下载地址:html5游戏掷骰子源码.pdf
留言与评论(共有 0 条评论) |