原生js结合html5制作简易的双色子游戏

标签:关于我们    日期:2017-11-03 09:35    录入:汇盛国际平台    浏览:

  

                
    ?html5???IE9+?firefoxchrome?

  
    

  ?
  1??????1-6??2-12е
  2??? 7 11???? ??
  3?2312 ?? ??
  4?45678910 ???
  57 ???? ??
  6???ε?? ??
  7???ε??????
  ?
  ????????·??
  
  
  
  
  /**  ?

  ??????1-6??2-12е  ??? 7 11???? ??

  ?2312 ?? ??

  ?45678910 ???

  7 ???? ??

  ???ε?? ??

  ???ε??????

  game:{?

  }  Stage={  add(thing) //?

  addEvent(type,handler)  redraw() //?thing  }  Thing={//  draw(canvas)//?canvas?thing  isScope(x,y) //canvasλ?boolean  //ж?thing?Χ true?false  addEvent(type,handler) // //?

  }  ??

  ????

  1? ?? ??

  2? ??

  3? ??

  **/  function Stage(canvas){  this.canvas=document.getElementById(canvas);  this.ctx=this.canvas.getContext('2d');  this.ctx.lineWidth=1;  this.ctx.strokeStyle='rgb(255,0,0)';  this.width=this.canvas.width;  this.height=this.canvas.height;  this.things=[];  this.addEvent=[];  this.rule={};  }  Stage.prototype.setings=function(){};  Stage.prototype.draw=function(){  for(var thing in this.things){  if(this.things[thing] instanceof Array){  for(var i=0;i 0 ? ('?ε['+this.rule.integral.join(',')+']'):'')+this.rule.hasNext+'
';  document.getElementById('log').innerHTML=html + tmp;  }  Stage.prototype.clean=function(){  for(var i=0;i 6)  this.porints=tmp;  this.draw_porints();  }  Disc.prototype.draw_porints=function(){  var radius=this.width/7;  if(this.porints==1){//?1???λεм(width/2,height/2) ??width/4  draw_porint(this.x + (this.width/2),this.y + (this.height/2),this.width/4,this.stage);  }else if(this.porints==2){//??λ(width/2,(height/7)*2,?λ(width/2,(height/7)*5)  draw_porint(this.x + (this.width/2),this.y + ((this.height/7)*2),radius,this.stage);  draw_porint(this.x + (this.width/2),this.y + ((this.height/7)*5),radius,this.stage);;  }else if(this.porints==3){  draw_porint(this.x + ((this.width/10)*2),this.y + ((this.height/10)*2),radius,this.stage);  draw_porint(this.x + ((this.width/10)*5),this.y + ((this.height/10)*5),radius,this.stage);  draw_porint(this.x + ((this.width/10)*8),this.y + ((this.height/10)*8),radius,this.stage);  }else if(this.porints==4){  draw_porint(this.x + ((this.width/7)*2),this.y + ((this.height/7)*2),radius,this.stage);  draw_porint(this.x + ((this.width/7)*5),this.y + ((this.height/7)*2),radius,this.stage);  draw_porint(this.x + ((this.width/7)*2),this.y + ((this.height/7)*5),radius,this.stage);  draw_porint(this.x + ((this.width/7)*5),this.y + ((this.height/7)*5),radius,this.stage);  }else if(this.porints==5){  draw_porint(this.x + ((this.width/10)*2),this.y + ((this.height/10)*2),radius,this.stage);  draw_porint(this.x + ((this.width/10)*2),this.y + ((this.height/10)*8),radius,this.stage);  draw_porint(this.x + ((this.width/10)*5),this.y + ((this.height/10)*5),radius,this.stage);  draw_porint(this.x + ((this.width/10)*8),this.y + ((this.height/10)*2),radius,this.stage);  draw_porint(this.x + ((this.width/10)*8),this.y + ((this.height/10)*8),radius,this.stage);  }else if(this.porints==6){  draw_porint(this.x + ((this.width/7)*2),this.y + ((this.height/10)*2),radius,this.stage);  draw_porint(this.x + ((this.width/7)*5),this.y + ((this.height/10)*2),radius,this.stage);  draw_porint(this.x + ((this.width/7)*2),this.y + ((this.height/10)*5),radius,this.stage);  draw_porint(this.x + ((this.width/7)*5),this.y + ((this.height/10)*5),radius,this.stage);  draw_porint(this.x + ((this.width/7)*2),this.y + ((this.height/10)*8),radius,this.stage);  draw_porint(this.x + ((this.width/7)*5),this.y + ((this.height/10)*8),radius,this.stage);  }  }  Disc.prototype.redraw=function(){  this.clean();  this.porints=1;  this.draw_porints();  }  Disc.prototype.clean=function(){  this.stage.ctx.clearRect(this.x,this.y,this.width,this.height);  }  function draw_porint(x,y,radius,stage){  stage.ctx.beginPath();  stage.ctx.arc(x,y,radius,0,2*Math.PI,false);  stage.ctx.closePath();  stage.ctx.fill();  }  function CallBoard(x,y,stage){  this.x=x;  this.y=y;  this.width=360;  this.height=50;  this.stage=stage;  this.notices=[];  this.init();  }  CallBoard.prototype.init=function(){  this.stage.ctx.beginPath();  this.stage.ctx.strokeRect(this.x,this.y,this.width,this.height);  this.stage.ctx.closePath();  this.stage.ctx.stroke();  this.draw();  }  CallBoard.prototype.draw=function(){  for(var i=0;i

★★★小编:汇盛国际注册 整理文章,欢迎大家转载 ★★★
上一篇:Listloading.js移动端上拉下拉刷新组件
下一篇:没有了