📄 popo.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Hxyman Popo Ver 1.0_Demo:http://www.codefans.net</title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="Hxyman">
<style>
<!--
body { font-size: 10pt; font-weight: bold; font-family: Arial; background: #3473d2 }
.box { width:40px; height:40px;}
-->
</style>
</head>
<body>
<span id=Canvas></span>
<bgsound id="sound_main" loop=-1 />
<bgsound id="sound_current_1" loop=1 />
<bgsound id="sound_current_2" loop=1 />
<bgsound id="sound_current_3" loop=1 />
<bgsound id="sound_current_4" loop=1 />
<bgsound id="sound_current_5" loop=1 />
<SCRIPT LANGUAGE="JavaScript">
<!--
/*------------------------------------------------------*\
| WEB泡泡堂v2.0(javascript)
| 写于 2006-9-5
| 感谢CodeFans.net分流下载
| 最后修改于 2006-9-11
| Hxyman QQ:86815260 EMail:Hxyman at yahoo.com.cn
\*------------------------------------------------------*/
/*------------------------------------------------------*\
| 游戏控制:
| 控制1 方向:wsaf 放泡泡:space 切换道具:e 使用道具:f
| 控制2 方向:↑↓←→ 放泡泡:enter 切换道具:1 使用道具:0
\*------------------------------------------------------*/
/*-----------------------------------------------*\
| 模式改变:
| this.ControlPlayer = new Array(-1, -1);
| this.ControlPlayer[0]和this.ControlPlayer[1]分别表示控制1和控制2所控制的玩家ID,如果都为-1则为电脑对玩。
\*-----------------------------------------------*/
/*------------------------------------------------------*\
| 地图制作:
| 仿照以下格式
| 下一行为地图及音效资源的存放路径
| this.ResPath[this.ResPath.length] = "pirate";
| block上的字符说明:
| h:障碍(不可炸掉也不可移动)
| k:障碍(可以炸掉但不能被移动)
| y:水平障碍竖直隐藏(不可炸掉也不可移动)
| g:障碍(可以推动)
| 数字:玩家ID
| 下一行为block地图,周围一圈务必为"h"
| this.SetMap[this.SetMap.length] = new Array(
| "hhhhhhhhhhh",
| "hhkh h hkhh",
| "hk0 k kh",
| "hkh hkh hkh",
| "hk h kh",
| "hhkh k hkhh",
| "hkkk h kkkh",
| "hkkh 1 hkkh",
| "hhhhhhhhhhh"
| );
| 下一行为背景地图,周围一较务必为" "
| this.SetBackMap[this.SetBackMap.length] = new Array(
| " ",
| " wkwcwcwkw ",
| " kccckccck ",
| " ksesksesk ",
| " kcccsccck ",
| " wkwcccwkw ",
| " kkkcsckkk ",
| " qkwcccwkq ",
| " "
| );
\*------------------------------*/
function Player(x, y)
{
this.x = x;
this.y = y;
this.popo = 1; //可放泡泡数
this.remain = 1; //剩余泡泡数
this.power = 1; //威力
this.direct = 3; //方向
this.auto = 0;
this.go = 0; //是否正在运动
this.fly = 0; //是否能飞
this.speed = 1; //速度
this.speed_count = this.speed;
this.state = 1; //正常-1 假死-2 真死-0
this.hidden = 0; //隐身
this.addheight = new Array(-16, -46);
this.addwidth = new Array(0, 0);
this.moveto = new Array(0, 0); //目标位置
this.movepath = new Array(); //预设路径
this.equip_remain = new Array(0,0,0); //道具列表 踢泡泡 针 飞碟
this.equip_current = 0;
this.show = new Array("","","");
}
function Bulb(x, y)
{
this.display = 0;
this.player = -1;
this.wait = 0; //还剩多少时间爆破
this.power = 1; //威力
this.size = 40;
this.size_max = 40;
this.size_min = 38;
this.tendency = 0;
this.x = x;
this.y = y;
}
function Popo(ClassName)
{
this.GetRnd = function(Max){return Math.round(Math.random()*Max)}
this.ClassName = ClassName;
this.SetMap = new Array();
this.SetBackMap = new Array();
this.ResPath = new Array();
//海盗船
this.ResPath[this.ResPath.length] = "pirate";
this.SetMap[this.SetMap.length] = new Array(
"hhhhhhhhhhh",
"hhkh h hkhh",
"hk0 k kh",
"hkh hkh hkh",
"hk h kh",
"hhkh k hkhh",
"hkkk h kkkh",
"hkkh 1 hkkh",
"hhhhhhhhhhh"
);
this.SetBackMap[this.SetBackMap.length] = new Array(
" ",
" wkwcwcwkw ",
" kccckccck ",
" ksesksesk ",
" kcccsccck ",
" wkwcccwkw ",
" kkkcsckkk ",
" qkwcccwkq ",
" "
);
//鬼屋
this.ResPath[this.ResPath.length] = "gui";
this.SetMap[this.SetMap.length] = new Array(
"hhhhhhhhhhh",
"hkkk 0kkkh",
"hhkhh hhkhh",
"hkk kkh",
"h h",
"h k k h",
"hhkhhghhkhh",
"hkkk1 kkkh",
"hhhhhhhhhhh"
);
this.SetBackMap[this.SetBackMap.length] = new Array(
" ",
" kkkccckkk ",
" hkjccjckh ",
" kkccccckk ",
" ccccccccc ",
" ckccccckc ",
" hkhzczhkh ",
" kkkccckkk ",
" "
);
//花园
this.ResPath[this.ResPath.length] = "garden";
this.SetMap[this.SetMap.length] = new Array(
"hhhhhhhhhhh",
"hk 0kh",
"hkk hhh kkh",
"hkkkhhhkkkh",
"hkkkg gkkkh",
"hkhhhghhhkh",
"hkhhh hhhkh",
"hkkk 1 kkkh",
"hhhhhhhhhhh"
);
this.SetBackMap[this.SetBackMap.length] = new Array(
" ",
" kccccccck ",
" tkccccckt ",
" ktkaccktk ",
" tktccctkt ",
" kccccccck ",
" tacccacct ",
" ktkcccktk ",
" "
);
//沙漠
this.ResPath[this.ResPath.length] = "desert";
this.SetMap[this.SetMap.length] = new Array(
"hhhhhhhhhhh",
"hhkhkhkhkhh",
"hk 1kkkkh",
"hh h h ykyh",
"hk hhh kkh",
"hykhhhhhkhh",
"hkkkk kh",
"hhkhkhkh0hh",
"hhhhhhhhhhh"
);
this.SetBackMap[this.SetBackMap.length] = new Array(
" ",
" nknknkhkn ",
" kcccckkkk ",
" nchchcyky ",
" kccmccckk ",
" ykncccckh ",
" ckkkcccck ",
" nkhknkhcn ",
" "
);
//小区
this.ResPath[this.ResPath.length] = "xiaoqu";
this.SetMap[this.SetMap.length] = new Array(
"hhhhhhhhhhh",
"h1 hg hkkh",
"h c g hgh",
"hhkhgg kkh",
"h h h h",
"hkk g hkhh",
"hgh gg h",
"hkkhg h 0h",
"hhhhhhhhhhh"
);
this.SetBackMap[this.SetBackMap.length] = new Array(
" ",
" cctxxxtkk ",
" ccfuiufdc ",
" dktuiuckk ",
" ftfuiuftf ",
" kkcuiutkd ",
" cdfuiufcc ",
" kktxxxtcc ",
" "
);
//仿照上面,可以在这里加入自定义地图
this.MapIndex = this.GetRnd(this.SetMap.length-1);
this.BulbMax = 50;
this.BulbWait = 70;
this.BulbBurst = 500;
this.PlayerRecovery = 5000;
this.Itv = null;
this.ControlPlayer = new Array(-1, -1);
this.DeadsetTimeOut = new Array();
this.SaysetTimeOut = new Array();
this.stop = new Array(0,0,0,0);
this.isend = 0;
this.SoundTurn = 1;
this.Player = new Array();
this.Bulb = new Array();
for (var i=0; i<this.BulbMax; i++)
{
this.Bulb[i] = new Bulb(0, 0);
}
this.MapMaxX = this.SetMap[this.MapIndex][0].length;
this.MapMaxY = this.SetMap[this.MapIndex].length;
this.BoxWidth = 40;
this.BoxHeight = 40;
this.Map = new Array();
this.BackMap = new Array();
this.BulbMap = new Array();
this.ReadMap = function(){
this.Map.length = 0;
this.BackMap.length = 0;
for (var i=0; i<this.MapMaxX; i++)
{
this.Map[i] = new Array();
this.BackMap[i] = new Array();
this.BulbMap[i] = new Array();
for (var j=0; j<this.MapMaxY; j++)
{
this.Map[i][j] = this.SetMap[this.MapIndex][j].charAt(i);
this.BackMap[i][j] = this.SetBackMap[this.MapIndex][j].charAt(i);
this.BulbMap[i][j] = -1;
}
}
}
//道具
this.Equip = new Array("","f","","","n","","","n","n","t", "n", "p","","p","r","","","","","");
this.EchoEquip = function(n){
return "<img width="+this.BoxWidth+" height="+this.BoxHeight+" src='res/equip_"+n+".gif' />";
}
this.DrawBox = function(left, top, width, height, id, str){
Canvas.insertAdjacentHTML("beforeEnd","<span id='"+id+"' style='position:absolute;left:"+left+";top:"+top+";width:"+width+";height:"+height+";'>"+str+"</span>");
}
this.InitBulb = function(n){
for (var i=0; i<n; i++)
{
Canvas.insertAdjacentHTML("beforeEnd","<img id='bulb"+i+"' style='position:absolute;width:"+this.BoxWidth+";height:"+this.BoxHeight+";display:none' src='res/popo.gif' />");
}
}
this.ReDrawBox = function(x, y, str){
document.getElementById("box"+x+"_"+y).innerHTML = str;
}
this.DrawBack = function(i, j, s){
var left = i*this.BoxWidth;
var top = j*this.BoxHeight;
var width = this.BoxWidth;
var height = this.BoxHeight;
var zIndex = 0;
this.DrawBox(left, top, width, height, "bgbg"+i+"_"+j, "<img src=res/"+this.ResPath[this.MapIndex]+"/bg_c.gif style='width:"+width+"px; height:"+height+"px' />");
switch (s)
{
case "d":
width=40; height=57; top-=17; zIndex=5; break;
case "h":
width=40; height=47; top-=7; zIndex=5; break;
case "t":
width=40; height=56; top-=16; zIndex=5;
break;
case "n":
width=40; height=65; top-=25; zIndex=5;
break;
case "m":
width=156; height=142; top-=62; zIndex=6;
break;
case "y":
width=40; height=71; top-=31; zIndex=5;
break;
case "f":
width=40; height=57; top-=17; zIndex=5;
break;
case "a":
width=115; height=83; top-=43; zIndex=5;
break;
case "j":
width=80; height=60; top-=20; zIndex=5;
break;
case "z":
width=40; height=132; top-=92; zIndex=5;
break;
case "q":
width=40; height=45; top-=5; zIndex=5;
break;
case "w":
width=40; height=48; top-=8; zIndex=5;
break;
case "s":
width=40; height=49; top-=9; zIndex=5;
break;
case "k":
width=40; height=44; top-=4; zIndex=5;
break;
case " ":
if (0==i)
{
if (0==j)
{
this.DrawBox(left, top, width, height, "border"+i+"_"+j, "<img src=res/border_lt.gif style='width:"+width+"px; height:"+height+"px;' />");
}
else if (this.MapMaxY==j+1)
{
this.DrawBox(left, top, width, height, "border"+i+"_"+j, "<img src=res/border_lb.gif style='width:"+width+"px; height:"+height+"px;' />");
}
else
{
this.DrawBox(left, top, width, height, "border"+i+"_"+j, "<img src=res/border_l.gif style='width:"+width+"px; height:"+height+"px;' />");
}
}
else if (this.MapMaxX==i+1)
{
if (0==j)
{
this.DrawBox(left, top, width, height, "border"+i+"_"+j, "<img src=res/border_rt.gif style='width:"+width+"px; height:"+height+"px;' />");
}
else if (this.MapMaxY==j+1)
{
this.DrawBox(left, top, width, height, "border"+i+"_"+j, "<img src=res/border_rb.gif style='width:"+width+"px; height:"+height+"px;' />");
}
else
{
this.DrawBox(left, top, width, height, "border"+i+"_"+j, "<img src=res/border_r.gif style='width:"+width+"px; height:"+height+"px;' />");
}
}
else if (0==j)
{
this.DrawBox(left, top, width, height, "border"+i+"_"+j, "<img src=res/border_t.gif style='width:"+width+"px; height:"+height+"px;' />");
}
else if (this.MapMaxY==j+1)
{
this.DrawBox(left, top, width, height, "border"+i+"_"+j, "<img src=res/border_b.gif style='width:"+width+"px; height:"+height+"px;' />");
}
return 0;
}
var str = "<img src=res/"+this.ResPath[this.MapIndex]+"/bg_"+s+".gif style='width:"+width+"px; height:"+height+"px;' />";
var id = ("k"==this.Map[i][j]?"brick":"bg")+i+"_"+j;
this.DrawBox(left, top, width, height, id, str);
document.getElementById(id).style.zIndex = zIndex;
}
this.DrawRes = function(i, j, s){
var left = i*this.BoxWidth;
var top = j*this.BoxHeight;
var width = this.BoxWidth;
var height = this.BoxHeight;
var str = "<img src=res/"+this.ResPath[this.MapIndex]+"/show_"+s+".gif style='width:"+width+"px; height:"+height+"px' />";
this.DrawBox(left, top, width, height, "box"+i+"_"+j, str);
}
this.InitPlayer = function(i, j, PlayerIndex){
this.Player[PlayerIndex] = new Player(i, j);
this.Player[PlayerIndex].auto = 1;
this.Player[PlayerIndex].show[0] = new Array("<img src=\"res/player"+PlayerIndex+"/n0.gif\" />", "<img src=\"res/player"+PlayerIndex+"/n0.gif\" />", "<img src=\"res/player"+PlayerIndex+"/n0.gif\" />", "<img src=\"res/player"+PlayerIndex+"/n0.gif\" />");
this.Player[PlayerIndex].show[1] = new Array("<img src=\"res/player"+PlayerIndex+"/n0.gif\" />", "<img src=\"res/player"+PlayerIndex+"/n1.gif\" />", "<img src=\"res/player"+PlayerIndex+"/n2.gif\" />", "<img src=\"res/player"+PlayerIndex+"/n3.gif\" />");
this.Player[PlayerIndex].show[2] = new Array("<img src=\"res/player"+PlayerIndex+"/d.gif\" />", "<img src=\"res/player"+PlayerIndex+"/d.gif\" />", "<img src=\"res/player"+PlayerIndex+"/d.gif\" />", "<img src=\"res/player"+PlayerIndex+"/d.gif\" />");
this.Player[PlayerIndex].show[3] = new Array("<img src=\"res/player"+PlayerIndex+"/n0.gif\" /><br><img width=40 src=\"res/show_f.gif\" />", "<img src=\"res/player"+PlayerIndex+"/n1.gif\" /><br><img width=40 src=\"res/show_f.gif\" />", "<img src=\"res/player"+PlayerIndex+"/n2.gif\" /><br><img width=40 src=\"res/show_f.gif\" />", "<img src=\"res/player"+PlayerIndex+"/n3.gif\" /><br><img width=40 src=\"res/show_f.gif\" />");
this.DrawBox(i*this.BoxWidth, j*this.BoxHeight, this.BoxWidth, this.BoxHeight, "player"+PlayerIndex, this.Player[PlayerIndex].show[0][3]);
document.getElementById("player"+PlayerIndex).style.zIndex = 10;
}
this.FreshPlayerPos = function(who){
if (0==this.Player[who].state) return 0;
document.getElementById("player"+who).style.left = this.Player[who].x*this.BoxWidth+this.Player[who].addwidth[this.Player[who].fly];
document.getElementById("player"+who).style.top = this.Player[who].y*this.BoxHeight+this.Player[who].addheight[this.Player[who].fly];
if (1==this.Player[who].fly)
document.getElementById("player"+who).innerHTML = this.Player[who].show[3][this.Player[who].direct];
else
document.getElementById("player"+who).innerHTML = this.Player[who].show[this.Player[who].state][this.Player[who].direct];
document.getElementById("player"+who).style.display = 0==this.Player[who].hidden?'':'none';
}
this.InitMap = function(){
this.ReadMap();
this.Player.length = 0;
for (var i=0; i<this.MapMaxX; i++)
{
for (var j=0; j<this.MapMaxY; j++)
{
this.DrawBack(i, j, this.BackMap[i][j]); //背景地图
switch(this.Map[i][j])
{
case "m":
case "g":
this.DrawRes(i, j, this.Map[i][j]);
break;
case "k":
case " ":
this.DrawBox(i*this.BoxWidth, j*this.BoxHeight, this.BoxWidth, this.BoxHeight, "box"+i+"_"+j, "");
break;
case "h": //设置障碍
break;
case "y":
this.DrawBox(i*this.BoxWidth, j*this.BoxHeight, this.BoxWidth, this.BoxHeight, "box"+i+"_"+j, "");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -