电脑或手机
HBuilder
1打开HBuilder,点击文件+新建,输入项目名,点击完成
index.html文件,首先导入css和js文件,以下是部分主页代码:
Level:
Lines:
Score:
Time:
方向键进行移动和翻转
编辑style.css样式文件,以下是部分详细代码:body { overflow: hidden; background: #d7d7d7;} #tetris { width: 360px; border: 1px solid black; padding: 20px; } #canvas { width: 200px; height: 440px; background-color: #000; position: relative; color: #fff; } #canvas h1 { margin: 0; padding: 0; text-align: center; font-size: 30px; padding-top: 200px; } .piece { border: 1px solid white; position: absolute; } .square { position: absolute; width: 19px; height: 19px; border: 1px solid white; } .type0 { background-color: #A000F0;} .type1 { background-color: #00F0F0;} .type2 { background-color: #F0A000;} .type3 { background-color: #0000F0;} .type4 { background-color: #00F000;} .type5 { background-color: #F00000;} .type6 { background-color: #F0F000;} #next_shape { position: relative; background-color: #000; border: 1px solid white; width: 110px; height: 110px; } #info { background-color: #000; color: #fff; float: right; width: 110px; height: 420px; padding: 10px;}
编辑index.js文件,以下是部分代码:if(!Array.prototype.eachdo){ Array.prototype.eachdo = function(fn){ for (var i=0; i < this.length; i++){ fn.call(this[i], i); } };}if(!Array.prototype.remDup){ Array.prototype.remDup = function(){ var temp = []; for(var i =0; i < this.length; i++){ var bool = true; for (var j = i+1; j < this.length; j++){ if(this[i] === this[j]){ bool = false;} } if(bool === true){temp.push(this[i]);} } return temp; }}
5需要的代码,现在我们都写完了,把页面切换到index.html上点击工具栏上的运行,选择一种浏览器,就可以查看效果了
6测试正常,让我们来愉快的玩耍吧,如果需要完整代码,请留下联系方式,小编会把完整代码送上
- 1
俄罗斯方块如何用html5编辑
- 2
怎样快速创建免费qq群
- 3
常用的公众号粉丝裂变的两种方法
- 4
教你一招加qq群的绝招,通过率超高
- 5
怎样进行夏日露腿大作战短裤的魅力杀很大
- 6
qq群如何设置加群方式
- 7
包皮水肿怎么消除
- 8
与你怎么设置拉我进群的方式?
- 9
飞书怎么创建群聊
- 10
2016一级建造师考试经验
- 11
ORACLE学习记:[11]如何Oracle DBA 快速入门
- 12
护书角的折法
- 13
如何选择移民香港方式
- 14
样式精美的年会h5邀请函制作步骤解读
- 15
戴尔笔记本怎么设置电脑系统的字体
- 16
华为mate20 pro字体样式在哪设置?怎么更换字体
- 17
FreeMind如何设置其他字体样式
- 18
ps如何导入字体文件 ps字体怎么导入样式
- 19
如何把从网页上复制的带底色的文字在word上去掉
- 20
如何安装字体文件
- 21
Premiere如何添加字体?