游戏唯一的一个规则,我们只需要不断踩着黑色方块前进即可,这里根据方向键来踩白块
在规定时间内,每走一次分数加100
游戏内的每一排都是一个有四个元素的数组,当正确的踩到黑块前进后,前一个数组内所有的对象样式属性(backgroundColor)赋值给其后一个数组内的对应位置处的对象,便实现了前进的功能,很简单的思想
*{padding: 0; margin: 0; } .div_bg { width: 410px; height: 512px; margin-top: 10px; border: 1px solid black; box-shadow: 0px 0px 20px #102327; } #score{ margin-top: 10px; color: #365669; margin:0 auto; width: 350px; height: 80px; } .span_1 { font-size: 3em; } .box_list { border-radius: 100%; text-align: center; line-height: 100px; color: red; font-size: 2em; } .box_list_1 { border-radius: 100%; box-shadow: 0px 0px 20px #ff5026; text-align: center; line-height: 100px; color: red; font-size: 2em; } .img{ margin: 0 auto; margin-top: 15px; } .over{ border: 2px solid #23f00f; border-radius: 20%; box-shadow: 0px 0px 5px red,0px 0px 10px blue,0px 0px 15px white; top: 200px; left: 50%; margin-left: -150px; color: black; line-height: 50px; text-align: center; font-size: 20px; } .newGame{ border: 2px solid #23fdff; border-radius: 20%; box-shadow: 0px 0px 5px red,0px 0px 10px blue,0px 0px 15px green; top: 350px; left:50%; margin-left: -50px; color: white; font-size: 16px; z-index: 9999; } .newGame:hover{ border: 2px solid #c05e8c; color: #A1FEDC; } #clock{ font-size: 4em; color: red; margin:0 auto; width: 350px; height: 80px; } 00:00:20:00
总结
以上所述是小编给大家介绍的Javascript别踩白块儿(钢琴块儿)小游戏实现代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对考高分网网站的支持!



