争怎路由网:是一个主要分享无线路由器安装设置经验的网站,汇总WiFi常见问题的解决方法。

未完成的JS作品之二:应用面向对象思想写的俄罗斯方块

时间:2024/7/2作者:未知来源:争怎路由网人气:

y>=this.height)
return false;
else if (this.Box.rows(y).cells(x).borderColorDark == '#ffffff')
return false;
else
return true;
}
this.dot = function(x,y) {
if (this.checkDot(x,y))
with (this.Box.rows(y).cells(x)) {
borderColorDark = '#FFFFFF';
borderColorLight = '#808080';
}
}
this.clearDot = function(x,y) {
with (this.Box.rows(y).cells(x)) {
borderColorDark = '#C0C0C0';
borderColorLight = '#C0C0C0';
}
}
this.eraseLine = function() {
var line = 0, ny=this.height-1;
for (var y=this.height-1;y>=0;y--) {
var erase=true;
for (var x=0;x<this.width;x++)
if (this.checkDot(x,y)) {
this.clearDot(x,ny);
erase=false;
}
else
this.dot(x,ny);
if (!erase)
ny--;
else
line++;
}
return line;
}
this.clear=function() {
for (var y=0;y<this.height;y++)
for (var x=0;x<this.width;x++)
this.clearDot(x,y);
}
}
function pos(x,y) {
this.x = x;
this.y = y;
return this;
}
function block(obj,Shape) {
this.x = 0;
this.y = 1;
this.obj = obj;
this.shape = new Array();
for (var i=0;i<Shape.length;i+=2)
this.shape[i>>1] = new pos(Shape[i],Shape[i+1]);
this.setObj = function(obj) {
this.obj = obj;
}
this.turn = function() {
var i,tmp;
with (this) {
for (i=1;i<shape.length;i++) {
tmp = shape[i].y;
shape[i].y = shape[i].x;
shape[i].x = shape[0].y - tmp;
}
tmp=shape[0].x; shape[0].x=shape[0].y; shape[0].y=tmp;
if (!check()) {
for (i=1;i<shape.length;i++) {
tmp = shape[i].x;
shape[i].x=shape[i].y;
shape[i].y=shape[0].x-tmp;
}
tmp=shape[0].x; shape[0].x=shape[0].y; shape[0].y=tmp;
}
}
}
this.check = function() {
with (this)
for (var i=1;i<shape.length;i++)
if (!obj.checkDot(shape[i].x+x,shape[i].y+y))
return false;
return true;
}
this.left = function() {
with (this) {
x--;
if (!check())
x++;
}
}
this.right = function() {
with (this) {
x++;
if (!check())
x--;
}
}
this.down = function() {
with (this) {
y++;
if (!check()) {
y--;
return false;
}
}
return true;
}
this.clear = function() {
with (this)
for (var i=1;i<shape.length;i++)
obj.clearDot(shape[i].x+x,shape[i].y+y);
}
this.draw = function() {
with (this)
for (var i=1;i<shape.length;i++)
obj.dot(shape[i].x+x,shape[i].y+y);
}
}

var Hiscore=0, score=0, line=0, level=1, speed=1500, handle=NaN;

function keyPlay() {
Block.clear();
switch (window.event.keyCode) {
case 73:
case 105:Block.turn(); break;
case 74:
case 106:Block.left(); break;
case 75:
case 107:if (!isNaN(handle))
window.clearTimeout(handle);
down();
break;
case 76:
case 108:Block.right();
}
Block.draw();
}
function keyWait() {
if (window.event.keyCode==115

关键词:未完成的JS作品之二:应用面向对象思想写的俄罗斯方块




Copyright © 2012-2018 争怎路由网(http://www.zhengzen.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版