js游戏 俄罗斯方块 源代码
来源:蓝色理想 时间:2008-01-24 13:14:00
javascript版 俄罗斯方块(Russian box)小游戏,喜欢的朋友可以玩玩。
对源代码感兴趣的朋友也可以研究一下。
玩法介绍:
可以输入1-9表示速度,9速度最快。
4个方向键控制游戏方向,↑变形,暂停是空格键。
开始游戏:俄罗斯分块
部分js源代码:
function ShowBlock(x,y,block_type,color){
for (var i=0;i<block_tbl.rows.length;i++){
for (var j=0;j<block_tbl.rows(i).cells.length;j++){
var d2 = i * 4 + j;
if (block_type[d2]==1){
block_tbl.rows(i).cells(j).style.background = color;
}
else{
block_tbl.rows(i).cells(j).style.background = "";
}
}
}
block_div.style.pixelLeft=x;
block_div.style.pixelTop=y;
}
function ShowBlock1(x,y,block_type,color,obj_tabID,obj_divID){
for (var i=0;i<obj_tabID.rows.length;i++){
for (var j=0;j<obj_tabID.rows(i).cells.length;j++){
var d2 = i * 4 + j;
if (block_type[d2]==1){
obj_tabID.rows(i).cells(j).style.background = color;
}
else{
obj_tabID.rows(i).cells(j).style.background = "";
}
}
}
obj_divID.style.pixelLeft=x;
obj_divID.style.pixelTop=y;
}
function Change(inc){
var type = curBlock.substr(0,4);
var num = curBlock.substr(curBlock.length-1);
num = parseInt(num) + inc;
if (num>4||num<1) num -= 4*inc;
type += num;
eval("arr_tmp = " + type + ";");
if (CanMove(curX,curY,arr_tmp)){
curBlock = type;
eval("arr_curBlock = " + curBlock + ";");
eval("ShowBlock(block_div.style.pixelLeft,block_div.style.pixelTop," + curBlock + ",colors[" + cid + "]);");
}
}
function CanMove(x,y,block){
for (i=0;i<4;i++){
for (j=0;j<4;j++){
if (block.getd(i,j,4)&table.getd(y/n_IncStep+i,x/n_IncStep+j,16)) return false;
}
}
return true;
}
function NewBlock(){
curBlock = nextBlock;
cid = ncid;
bid = Math.round(Math.random()*(blocks.length-1));
ncid = Math.round(Math.random()*(colors.length-1));
nextBlock = blocks[bid];
eval("arr_curBlock = " + curBlock + ";");
eval("ShowBlock(120,0," + curBlock + ",colors[" + cid + "]);");
eval("arr_curBlock = " + curBlock + ";");
eval("ShowBlock1(466,116," + nextBlock + ",colors[" + ncid + "],nblock_tbl,nblock_div);");
}
function SaveBlock(){
for (i=0;i<4;i++){
for (j=0;j<4;j++){
table[(curY/n_IncStep+i)*16+curX/n_IncStep+j]|=arr_curBlock[i*4+j];
标签:代码,游戏,js,俄罗斯方块
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python3爬虫中引用Queue的实例讲解
2023-07-15 19:43:48
课程讲解 如何使用SQL Server校勘功能
2009-01-13 13:27:00
![](https://img.aspxhome.com/file/UploadPic/20091/200911419550985.jpg)
Python数据分析之缺失值检测与处理详解
2021-10-04 01:09:08
![](https://img.aspxhome.com/file/2023/5/65085_0s.png)
基于Python制作一键桌面整理工具
2022-08-22 11:45:52
![](https://img.aspxhome.com/file/2023/1/131281_0s.jpg)
js获取浏览器高度 窗口高度 元素尺寸 偏移属性的方法
2024-04-16 08:55:16
![](https://img.aspxhome.com/file/2023/0/136820_0s.jpg)
Oracle对于死锁的处理方法
2024-01-13 03:10:48
5分钟快速掌握Python定时任务框架的实现
2023-05-31 10:19:45
![](https://img.aspxhome.com/file/2023/6/110196_0s.png)
Python批量裁剪图片的思路详解
2023-05-11 03:55:59
![](https://img.aspxhome.com/file/2023/5/78545_0s.png)
Python实现列表拼接和去重的三种方式
2021-05-02 23:43:54
asp按关键字查询XML的代码
2011-04-21 11:10:00
Session的工作机制详解和安全性问题(PHP实例讲解)
2024-05-03 15:29:39
![](https://img.aspxhome.com/file/2023/2/129842_0s.png)
禁止在网页里面是用搜狗的云输入法
2009-11-29 15:50:00
Jupyter安装拓展nbextensions及解决官网下载慢的问题
2023-11-24 20:50:54
![](https://img.aspxhome.com/file/2023/8/133898_0s.jpg)
Python迭代器和生成器介绍
2022-03-22 07:41:24
![](https://img.aspxhome.com/file/2023/2/97772_0s.png)
Python3.10接入ChatGPT实现逐句回答流式返回
2022-03-04 04:45:30
![](https://img.aspxhome.com/file/2023/1/120561_0s.png)
python numpy和list查询其中某个数的个数及定位方法
2021-04-29 01:36:50
ShardingSphere数据库读写分离算法及测试示例详解
2024-01-19 06:21:09
![](https://img.aspxhome.com/file/2023/7/76607_0s.png)
JavaScript中尽量用局部变量的原因[译]
2009-02-20 13:45:00
![](https://img.aspxhome.com/file/UploadPic/20092/20/01-88s.jpg)
Python中使用PIPE操作Linux管道
2022-02-10 18:25:25
![](https://img.aspxhome.com/file/2023/4/90594_0s.png)
微信小程序实现倒计时调用相机自动拍照功能
2024-04-17 10:26:38