日期:2014-05-16 浏览次数:20564 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <style> div {display:block;background-color:black;position:absolute;font:17px Tahoma;color:#fff;} <!-- 层 --> span {float:left;background-color:gray;width:12px;height:12px;border:4px gray outset;margin:0 1 1 0;overflow:hidden;} <!-- 游戏区单体方块 --> p {float:left;width:8px;height:8px;border:2px gray outset;overflow:hidden;margin:0;padding:0} <!-- 预览区单体方块 --> #main {width:375px;height:430px;display:block;background-color:gray;position:relative;} <!-- 全面版 --> #body {width:241px;height:401px;left:15px;top:15px;border:1px solid #999;} <!-- 主游戏区 --> #score {width:80px;height:24px;left:270px;top:15px;padding:4px;} <!-- 计分区 --> #level {width:80px;height:24px;left:270px;top:50px;padding:4px;} <!-- 等级区 --> #next {width:50px;height:50px;left:270px;top:85px;border:19px black solid;} <!-- 预览区 --> #ctrl {width:80px;height:55px;left:270px;top:360px;padding:4px;text-align:center;background-color:gray} <!-- 按钮区 --> #ctrl button{width:80px;height:25px;} <!-- 按钮 --> </style> <script> //By: X!ao_f QQ:120000512 var G = { fs:[], // 游戏区点阵 fn:[], // 预览区点阵 score:0, l:['#9F0','#FF3','#F33','#C0C','#33C','#0F3','#F93'],// 颜色选择器 v:[0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0x801,0xFFFF], // 游戏区行点阵 d:[[0xCC00],[0x4444,0xF0],[0x8C40,0x6C00],[0x4C80,0xC600],[0x44C0,0x8E00,0xC880,0xE200],[0x88C0,0xE800,0xC440,0x2E00],[0x4E00,0x8C80,0xE400,0x4C40]], // 方块造型点阵 init:function(){ var body = document.getElementById('body'); var next = document.getElementById('next'); for(var i=0;i<240;i++){ // 以游戏区单体方块填充点阵 G.fs.push(body.appendChild(document.createElement("span"))); } for(var i=0;i<16;i++){ // 以预览区单体方块填充点阵 G.fn.push(next.appendChild(document.createElement("p"))); } G.domScore = document.getElementById('score'); G.domLevel = document.getElementById('level'); document.onkeydown=function(e){G.event(e||window.event,0)}; // 页面按键事件控制转移到闭包 G.rand(); G.next(); }, timeTesk:function(){ if(G.pause)return;// 如果暂停按钮按下,则停止该函数运行 if(!G.move(G.x, G.y+1, G.t)){ // 是否能继续下移 var s = 0; for(var i=0;i<19;i++){ G.v[i]=G.v[i]|G.m[i]; if(G.v[i]==0xFFF){// 根据行点阵判断是否已达到可消除行 for(var k=i;k>0;k--){ G.v