首先先来看一下效果图
如果感兴趣的就来看一下Js源码吧
//计分板
var board = {
dom: document.getElementById("score"),
maxLost: 3, //最大丢失量
lost: 0, //当前丢失了多少个
score: 0, //当前分数
render: function() {
//显示
this.dom.innerHTML =
"<p>得分:" +
this.score +
"</p><p>丢失:" +
this.lost +
" / " +
this.maxLost +
"</p>";
},
//增加一个丢失数
addLost: function() {
if (this.lost === this.maxLost) {
return; //游戏已经结束了
}
this.lost++;
if (this.lost === this.maxLost) {
//丢失量达到最大
game.gameOver();
}
this.render();
},
reset: function() {
this.lost = 0;
this.score = 0;
this.render();
},
//增加得分
addScore: function(number) {
if (this.lost === this.maxLost) {
//已经结束了
return;
因篇幅问题不能全部显示,请点此查看更多更全内容