js写一个开心消消乐
Posted 肥学
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js写一个开心消消乐相关的知识,希望对你有一定的参考价值。
目录标题
展示
游戏背景
一天晚上,天空中掉下一颗神奇的豌豆种子,正好落在了梦之森林的村长屋附近,种子落地后吸收了池塘的水分,迅速成长,一夜之间变成参天大藤蔓…… 第二天早上,村民们醒来后看到巨大的藤蔓都惊呆了,聚在一起议论纷纷。有人说他似乎看到村长的房子在高耸入云的藤蔓上,房子似乎还在上升,有人号召说应该爬上去救村长,玩家需要爬到藤曼顶部救出村长
游戏规则
把三个颜色相同的小动物连成一条直线,即可消除。达到指定的目标通关后。游戏的模板有四种分别是分数过关、指定消除、获得金豆荚、云朵关卡。
源码部分
主页面js部分调用了微信分享api
</script>
<div id="share" style="display: none">
<img width="100%" src="bitmap/share.png" style="position: fixed; z-index: 9999; top: 0; left: 0; display: " ontouchstart="document.getElementById('share').style.display='none';">
</div>
<script>
var mebtnopenurl = "http://mp.weixin.qq.com/s?__biz=MzA5MzU2MjU3Mw==&mid=218850712&idx=1&sn=53bfed8c43391843a6268706ccda8eb2&scene=1&key=1936e2bc22c2ceb5b8b45ee0ef26a5cc01639c3411c2cfd0bd74efb6f0a180003056abc9700e348732a0a5c963462d2f&ascene=1&uin=MjgxMTA4MTUwMQ%3D%3D&devicetype=Windows+7&version=61000721&pass_ticket=w4kQ%2FSFhaY2mmOE87ChVgbTRWP%2BctOhqXukbldnl%2FXb4%2BOxgCyIxSdzUjax%2FUmHK";
var tit = "";
var DFW =
appId: "",
TLImg: "kaixinlian.jpg",
url: "http://www.mycodes.net/166/",
title: "开心消消乐-多多游戏",
desc: "我消,我消,我消...!"
;
var onBridgeReady = function ()
WeixinJSBridge.on('menu:share:appmessage', function (argv)
WeixinJSBridge.invoke('sendAppMessage',
"appid": DFW.appId,
"img_url": DFW.TLImg,
"img_width": "120",
"img_height": "120",
"link": DFW.url,
"title": DFW.title + tit,
"desc": DFW.desc
);
);
WeixinJSBridge.on('menu:share:timeline', function (argv)
WeixinJSBridge.invoke('shareTimeline',
"appid": DFW.appId,
"img_url": DFW.TLImg,
"img_width": "120",
"img_height": "120",
"link": DFW.url,
"title": DFW.title + tit,
"desc": DFW.desc
);
);
;
if (document.addEventListener)
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
else if (document.attachEvent)
document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
function do_share(score)
document.title = "我获得了" + score + "分,一起来消星星吧!";
document.getElementById("share").style.display = "";
window.DFW.title = document.title;
function dp_submitScore(level,score)
//alert("你获得" + score + "分");
if (score > 5000)
if (confirm("你获得了" + score + " 要不要通知下小伙伴们呢?"))
do_share(score);
</script>
对关卡的地图设置
level: [
time: 300,
map: [
[, , , , , , , , ],
[, , , 0, 0, 0, , , ],
[, , 0, 0, 0, 0, 0, , ],
[, 0, 0, 1, 0, 1, 0, 0],
[, 0, 1, 0, 1, 0, 1, 0],
[, 0, 1, 1, 0, 1, 1, 0],
[, , 0, 0, , 0, 0, , ]
]
,
time: 300,
map: [
[, , , , , , , , ],
[, , 0, 0, 0, 0, 0, , ],
[, 0, 0, 1, 1, 1, 0, 0],
[, 0, 0, 1, , 1, 0, 0],
[, 0, 0, 1, 1, 1, 0, 0],
[, , 1, 1, 0, 1, 1, , ],
[, 0, 0, 0, 0, 0, 0, 0]
]
,
time: 300,
map: [
[, 0, 0, 0, 0, 0, 0, 0],
[, , 0, 0, 1, 0, 0, , ],
[, , , 1, 1, 1, , , ],
[, , , , 4, , , , ],
[, , , 0, 0, 0, , , ],
[, , 0, 0, 1, 0, 0, , ],
[, 0, 1, 1, 1, 1, 1, 0],
[0, 0, 0, 1, 1, 1, 0, 0, 0]
]
,
time: 300,
map: [
[, 0, 0, 0, 0, 0, 0, 0],
[, , 0, 0, 0, 0, 0, 0],
[, 0, 1, 0, , 1, 1, 0],
[, 0, 1, , 0, 0, 1, 0],
[, 0, 1, 0, 0, , 1, 0],
[, 0, 1, 1, , 0, 1, 0],
[, 0, 0, 0, 0, 0, 0, , ]
]
,
time: 300,
map: [
[0, 1, 0, 0, 0, 0, 0, 1, 1],
[0, 1, 0, 0, 0, 0, 1, 1, 0],
[, 0, 0, 0, 0, 1, 1, 0, 0],
[, , 0, 0, 1, 1, 0, 0, 0],
[, , , 1, 1, 4, 4, 4, 4],
[, , , , 0, 0, 0, 0, 0],
[, , , , , 0, 0, 1, 1],
[, , , , , , 0, 0, 0]
]
,
time: 300,
map: [
[, 0, 0, 0, , 0, 0, 0],
[, 0, 0, 0, , 0, 0, 0],
[0, 0, 0, 0, , 0, 0, 0, 0],
[0, 0, 0, 0, , 0, 0, 0, 0],
[1, 1, 1, 1, , 1, 1, 1, 1],
[0, 4, 4, 4, , 4, 4, 4, 0],
[, 1, 1, 1, , 1, 1, 1],
[, 0, 0, 0, , 0, 0, 0]
]
,
time: 360,
map: [
[, , , 0, 0, 0, , , ],
[, , 0, 0, 1, 0, 0, , ],
[, , 0, 1, 1, 1, 0, , ],
[, , 0, 5, 5, 5, 0, , ],
[, 0, 0, 1, 1, 1, 0, 0],
[, 0, 0, 2, 2, 2, 0, 0],
[, 1, 1, 0, 0, 0, 1, 1],
[, 0, 0, , 0, , 0, 0]
]
,
time: 360,
map: [
[0, 0, 0, 0, , 0, 0, 0, 0],
[, 0, 0, 0, , 0, 0, 0],
[, , 0, 0, 0, 0, 0, , ],
[, 0, 2, 2, 0, 2, 2, 0],
[0, 0, , 0, 0, 0, , 0, 0],
[1, 1, 1, 0, , 0, 1, 1, 1],
[0, 1, 1, 1, 0, 1, 1, 1, 0],
[, 0, 0, 0, , 0, 0, 0]
]
,
time: 360,
map: [
[1, 1, 1, 0, 0, 0, 1, 1, 1],
[1, 2, 1, 0, , 0, 1, 2, 1],
[1, 1, 1, , 0, , 1, 1, 1],
[0, 0, , 0, 0, 0, , 0, 0],
[0, , 0, 0, 0, 0, 0, , 0],
[, , 0, 5, 5, 5, 0, , ],
[, 0, 0, 1, 2, 1, 0, 0],
[, 0, 0, 1, 1, 1, 0, 0]
]
,
time: 300,
map: [
[, , , 0, 0, 0, , , ],
[, , 0, 1, 1, 1以上是关于js写一个开心消消乐的主要内容,如果未能解决你的问题,请参考以下文章