首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

【软件分享】貌似这两天围堵游戏挺受欢迎,升级为自定义关卡版本。解决方法

2012-04-23 
【软件分享】貌似这两天围堵游戏挺受欢迎,升级为自定义关卡版本。有谁设计的关卡不错来分享一下。收集经典的关

【软件分享】貌似这两天围堵游戏挺受欢迎,升级为自定义关卡版本。

有谁设计的关卡不错来分享一下。

收集经典的关卡:http://www.renrousousuo.com/Rounded.aspx
自定义关卡:http://www.renrousousuo.com/Scripts/Rounded.html

JScript code
/*--标题:围堵设计:王集鹄博客:http://blog.csdn.net/zswang日期:2009年12月5日--*///2009年12月6日 王集鹄 添加 地图参数、马和象的走法、操作次数、图像样式的兼容 function Box(options) {    options = options || {};    var self = this;    this.rowCount = options.rowCount || 15; // 行数    this.colCount = options.colCount || 15; // 列数    this.kickCount = options.kickCount || 1; // 玩家操作多少次一个周期    this.parent = options.parent || document.body; // 容器    this.caption = options.caption || "Replay"; // 标题    this.map = (options.map || "").replace(/\s+/g, ""); // 地图数据        this.button = document.createElement("input");    this.button.type = "button";    this.button.value = this.caption;    this.button.onclick = function() {         self.replay();     };    this.parent.appendChild(this.button);    this.table_back = document.createElement("table");    this.table_back.className = "table_back";    this.table_back.cellPadding = "0px";    this.table_back.cellSpacing = "0px";    this.playing = false; // 是否在进行中    this.floors = {}; // 矩阵地板矩阵 [y,x]    for (var i = 0; i < this.rowCount; i++) {        var tr = this.table_back.insertRow(-1);        for (var j = 0; j < this.colCount; j++) {            var td = tr.insertCell(-1);            this.floors[i + "," + j] = new Floor({                td: td                , box: this                , pos: { x: j, y: i }            });        }    }    this.parent.appendChild(this.table_back);    this.replay();}// 重新开始Box.prototype.replay = function() {    this.playing = true;    this.mickeys = [];    this.step = 0;    var k = 0;    for (var i = 0; i < this.rowCount; i++) {        for (var j = 0; j < this.colCount; j++) {            var name = this.map.substr(k++, 1);            switch(name) {                case "1": case "x": case "w": case "c":                    this.floors[i + "," + j].setState("closed");                    break;                case "r": case "b": case "n": case "q":                    var mickey = new Mickey({name: name, box: this, pos: {x: j, y: i}});                    this.mickeys.push(mickey);                    break;                default:                    this.floors[i + "," + j].setState("blank");                    break;            }        }    }};// 下一个周期Box.prototype.kick = function() {    if (!this.playing) return;    this.step++;    if (this.step % this.kickCount != 0) return;    var count = 0;    var freedom = false;    for (var i = 0; i < this.mickeys.length; i++) {        if (this.mickeys[i].run()) count++;        if (this.mickeys[i].freedom) freedom = true;    }    if (freedom) // 有老鼠跑了        this.gameover();    else if (!count) this.win();};// 游戏结束Box.prototype.gameover = function() {    if (!this.playing) return;    this.playing = false;    if (this.ongameover)        this.ongameover();    else alert(this.caption + "跑掉了。o(╯□╰)o");};Box.prototype.win = function() {    if (!this.playing) return;    this.playing = false;    if (this.onwin)         this.onwin();    else alert(this.caption + "O(∩_∩)O成功!");};// 地板function Floor(options) {    options = options || {};    var self = this;    this.td = options.td || {};    this.td.innerHTML = "&nbsp;";    this.td.onclick = function() {        if (!self.box.playing) return; // 游戏已经结束        if (self.state != "blank") return;        self.setState("closed");        self.box.kick();        if (typeof playSound == "function") playSound("move"); // 播放声音    }    this.box = options.box || {};    this.pos = options.pos || {};    this.state = "blank";    this.doChange();}// 状态变化Floor.prototype.doChange = function() {    var className = "floor";    if (this.state == "blank" && (this.pos.x * this.pos.y == 0        || this.pos.x == this.box.colCount - 1        || this.pos.y == this.box.rowCount - 1)) // 边缘        className += " edge";    className += " " + this.state;    if (typeof this.arrow != "undefined")         className += " " + this.state + this.arrow;    if (this.td.className != className)        this.td.className = className;};Floor.prototype.setState = function(state, arrow) {    if (this.state == state) return;    this.state = state;    this.arrow = arrow;    this.doChange();};// 老鼠类function Mickey(options) {    options = options || {};    this.box = options.box || {};    this.pos = options.pos || {}; // 所在位置    this.name = options.name || "rook";     if (this.name.length == 1)        this.name = { "n": "knight", "q": "queen", "r": "rook", "b": "bishop" }[this.name];    this.route = []; // 逃跑路线    this.freedom = false; // 是否获得自由    this.move(this.pos);    this.offsets = this.types[this.name].offsets;}Mickey.prototype.types = {    "knight": {        caption: "?"        , offsets: [            { x: -2, y: -1 }            , { x: -1, y: -2 }            , { x: +2, y: -1 }            , { x: +1, y: -2 }            , { x: +2, y: +1 }            , { x: +1, y: +2 }            , { x: -2, y: +1 }            , { x: -1, y: +2 }        ]    }    , "queen": {        caption: "?"        , offsets: [            {x: 0, y: -1}            , {x: +1, y: 0}            , {x: 0, y: +1}            , {x: -1, y: 0}            , {x: -1, y: -1}            , {x: +1, y: -1}            , {x: +1, y: +1}            , {x: -1, y: +1}        ]    }    , "rook": {        caption: "?"        , offsets: [            {x: 0, y: -1}            , {x: +1, y: 0}            , {x: 0, y: +1}            , {x: -1, y: 0}        ]    }    , "bishop": {        caption: "?"        , offsets: [            {x: -1, y: -1}            , {x: +1, y: -1}            , {x: +1, y: +1}            , {x: -1, y: +1}        ]    }};// 移动位置Mickey.prototype.move = function(pos) {    pos = pos || {};    if (pos.x == this.x && pos.y == this.y) return;    if (this.box.floors[this.pos.y + "," + this.pos.x])        this.box.floors[this.pos.y + "," + this.pos.x].setState("blank");    this.pos = pos;    this.box.floors[this.pos.y + "," + this.pos.x].setState(this.name, this.arrow);    this.freedom = this.pos.x == 0 || this.pos.y == 0         || this.pos.x == this.box.colCount - 1        || this.pos.y == this.box.rowCount - 1;};// 老鼠跑Mickey.prototype.run = function() {    this.flags = {};    this.route = [];    if (this.search(this.pos, this.route)) {        var item = this.route.shift();        this.arrow = item.arrow;        this.move(item.pos);        return true;    }};// 搜索逃跑路径Mickey.prototype.search = function(pos, route) {    if (this.flags[pos.y + "," + pos.x]) return false;    this.flags[pos.y + "," + pos.x] = true; // 标记已经扫描    // 搜索直观的路径    var directions = {}; // 每个方向的路径    var min = -1; // 最短的距离    for (var i = 0; i < this.offsets.length; i++) {        directions[i 



调用示例:
JScript code
new Box({    caption: "第一关(堵車)"    , rowCount: 7    , colCount: 7    , map: "\0000000\0000000\0000000\000r000\0000000\0000000\0000000\    "});


本作品受wujinjian2008n帖子的启发【散分】花了一晚上写了个JavaScript小游戏 


[解决办法]
SF
[解决办法]
很强大,代码很简洁。就是看不懂。
[解决办法]

还围上瘾了...
[解决办法]

路过,围观帅哥~~LZ,头像是你本人不? 我咋感觉像是明星照?

[color=#FFFFFF]这么恶心的马屁。给分的时候你看着办[/color]
[解决办法]
不错,貌似最近js游戏很火呀,我也写过一个俄罗斯方块,最近想到一个更简洁的算法,可惜一直没时间去实现,等这个周末搞个更简洁的出来。
http://topic.csdn.net/u/20090810/10/34063f92-9156-4a68-b37c-0973ca5eafb3.html
[解决办法]
探讨
路过,围观帅哥~~LZ,头像是你本人不? 我咋感觉像是明星照?

这么恶心的马屁。给分的时候你看着办

[解决办法]
探讨
引用:
路过,围观帅哥~~LZ,头像是你本人不? 我咋感觉像是明星照?

这么恶心的马屁。给分的时候你看着办

你说对了,lz就是明星嘛

[解决办法]
支持 ,接分~````
[解决办法]
mark
[解决办法]
隐藏在白色背景下的阴谋~
[解决办法]
探讨
引用:
路过,围观帅哥~~LZ,头像是你本人不? 我咋感觉像是明星照?

这么恶心的马屁。给分的时候你看着办

你说对了,lz就是明星嘛

[解决办法]
JF
[解决办法]
有机会一定要学习这个代码!
[解决办法]

[解决办法]
jf
[解决办法]
大甲虫来顶起,lz好代码,游戏有意思~

[解决办法]
支持
[解决办法]
仔细看看。
[解决办法]
jf~
[解决办法]
游戏有意思~ 

[解决办法]
顶你没商量!
[解决办法]
jf
[解决办法]

[解决办法]
正在一边看,一遍写,先顶,接分
[解决办法]
牛人
[解决办法]
赫赫~~
------解决方案--------------------


不错 啊
[解决办法]
好东西,只能看了、其他一概不懂,那代码怎么调用法啊??
[解决办法]
支持
[解决办法]
看着就头晕
[解决办法]
41
[解决办法]
路过..
强大..
但是 CSDN告诉我
每天回帖即可获得10分可用分!
[解决办法]
牛 B ,顶

积分一个
[解决办法]
ffffffffffffffffffffffffffff
[解决办法]
路过......

[解决办法]
这个得得顶
[解决办法]
哇 好厉害
我是不懂啦
[解决办法]
楼主:问一下,这个版本没有源码吗?
[解决办法]
密密麻麻的代码?
看不懂呀!
[解决办法]
我也来顶一下

[解决办法]

[解决办法]
支持,不错的
[解决办法]
ORZ 白色……

探讨
引用:
引用:
路过,围观帅哥~~LZ,头像是你本人不? 我咋感觉像是明星照?

这么恶心的马屁。给分的时候你看着办

你说对了,lz就是明星嘛

多亏你引用,否则最后一句还看不到,哈哈

[解决办法]
LZ更新的很快啊,版本一个接一个啊
[解决办法]
不错的东西
[解决办法]
.
[解决办法]
好东西
[解决办法]
大甲虫来顶起,lz好代码,游戏有意思~ 

[解决办法]
挺好玩的,哈哈
[解决办法]
god 出来看外星人了
[解决办法]
zan qi
[解决办法]
jf
[解决办法]
好东西
[解决办法]
太有意思了,研究研究
[解决办法]
个网站是您开发的
挺好玩的
[解决办法]
拿个分
[解决办法]
学习了
[解决办法]
你牛。。。
------解决方案--------------------


dddddddddddddddddddddddddddddddddddd
[解决办法]
ding...........
[解决办法]
这么强大,绝对要顶
[解决办法]
zhenshi真是牛啊
[解决办法]
这太有顶的必要了
[解决办法]
不錯不錯,.呵呵...做的也很可愛..
[解决办法]
顶一下无罪哦!
[解决办法]
楼主太强大了,抽空好好学习一下。
[解决办法]
JF
[解决办法]
mark
[解决办法]
dingding
[解决办法]
学习
[解决办法]
厉害阿
[解决办法]
顶。。逛顶
[解决办法]
支持 ,接分~````
[解决办法]
~~~jF
[解决办法]
我顶
[解决办法]
顶```
[解决办法]
顶!!!!
[解决办法]

[解决办法]
伟大的LZ啊~~
[解决办法]
新号报道。
[解决办法]
郁闷,不会玩这游戏。。
[解决办法]
非常好啊。
[解决办法]
jf
[解决办法]
游戏规则是什么啊?没有看到说明!

[解决办法]
好东东,学习下
[解决办法]
很好 学习!
[解决办法]
.bishop{background-position:-128px 0;cursor:default;}
.bishop0{background-position:-128px 0;cursor:default;}
.bishop1{background-position:-160px 0;cursor:default;}
.bishop2{background-position:-192px 0;cursor:default;}
.bishop3{background-position:-224px 0;cursor:default;}

.queen{background-position:0 -64px;cursor:default;}
.queen0{background-position:0 -64px;cursor:default;}
.queen1{background-position:-32px -64px;cursor:default;}
.queen2{background-position:-64px -64px;cursor:default;}
.queen3{background-position:-96px -64px;cursor:default;}

[解决办法]
玩不过去

热点排行