<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>West Fighting / 西途决斗 - HTML5 GAME</title>
<style type="text/css">
body{margin:0px; padding:0; overflow-x:hidden;}
body,td,div,span,input,canvas{font-family:verdana,arial; font-size:12px;}
a:link, a:visited{font-family:verdana,arial; font-size:11px; color:#006699; text-decoration:underline;}
a:hover, a:active{font-family:verdana,arial; font-size:11px; color:#FF0033; text-decoration:none;}
#gameContainer{border:1px solid red;}
#gameCanvas{font-size:12px; font-family:verdana,arial; }
#infoPanel{font-family:verdana,arial; font-size:12px; border:1px solid #D63C06; display:block; padding:5px; background-color:#F9EFE9; overflow:hidden;}
#gameInfo{font-family:verdana,arial; font-size:11px; text-align:right; font-weight:normal; display:block; border-bottom:1px solid #999999;padding-bottom:3px;}
#controlPanel{padding:10px 0;}
.num01{font-family:verdana,arial; font-size:10px; padding:0 2px; font-weight:normal;}
.num02{font-family:verdana,arial; font-size:11px; padding:0 2px; font-weight:normal; color:#990000;}
a.a01:link, a.a01:visited{font-family:verdana,arial; font-size:12px; color:#006699; border:1px solid #999999; padding:2px 4px; margin:0 5px; text-decoration:none}
a.a01:hover, a.a01:active{font-family:verdana,arial; font-size:12px; color:#FFFFCC; border:1px solid #999999; padding:2px 4px; margin:0 5px; text-decoration:none; background-color:#990000}
</style>
</head>
<body onkeydown="javascript:keyPress(event);" onkeyup="javascript:keyRelease(event);">
<div id="gameContainer">
<canvas id="gameCanvas" width="1024">
<div id="gbTip">请使用支持HTML5的浏览器...</div>
</canvas>
</div>
<!--start: info panel-->
<div id="infoPanel">
<div id="gameInfo"><b>West Fighting[西途决斗]</b>, Version:1.2.0, Current Time:<span class="num02" id="cTime">2010-11-30 10:20:32</span>, Run Time:<span class="num02" id="rTime">0000</span>sec, created by <a target="_blank" title="^_^ welcome..." href="http://hi.csdn.net/shenzhenNBA">shenzhenNBA[CSDN]</a>, <a target="_blank" title="^_^ welcome..." href="http://blog.csdn.net/shenzhennba/">Blog</a> 2011-12-01(商用需授权...)</div>
<div id="controlPanel">
Cowboy Life:<span class="num02" id="cowboyLife">120</span>, Position:[X:<span class="num02" id="cowboyPX">0</span>, Y:<span class="num02" id="cowboyPY">0</span>]
Tribe man Active:<span class="num02" id="tmActive">0</span>, Death:<span class="num02" id="tmDeath">0</span>
control key: [ ↑,←, ↓, → ] or [ W,A,S,D ], fast + [ Ctrl ]
<a class="a01" href="javascript:gameSystem.gameStart();" title="开始">Start</a> <a class="a01" href="javascript:gameSystem.gamePause();" title="暂停">Pause</a> <a class="a01" href="javascript:gameSystem.gameContinue();" title="继续">Continue</a> <a class="a01" href="javascript:gameSystem.gameRestart();" title="结束当前重新开始游戏">Restart</a> <a class="a01" href="javascript:gameSystem.gameEnd();" title="结束游戏">End</a>
<a class="a01" title="游戏说明" href="javascript:void(0);">How to play</a> <span id="num"></span>
</div>
</div>
<!--end: info panel-->
<script language="javascript" type="text/javascript">
//This is old source code
//--------------------start: keep tribe move time define-------------
var timeController={
//function to controll the tribe man keep move in old direction some time and then change the move direction
//设置在上一次方向上持续移动的时间,超过该时间后,动态修正方向[以牛仔为目标]再持续在该方向上移动指定时间在修正方向,一直循环这个过程到死忙
//keepMoveTime 时间越短动态改变方向越快,朝牛仔目标移动越灵敏
i:0,
weakTipChangeTime:2,
weakTipShowTime:2,
t:0,
j:1,
bottleShowTime:90,
newBottleTime:30,
timeControllerID:"",
timeOn:function(){
//----------------start: about tribe man time control--------------------
for(this.t=0;this.t<gameSystem.tribeMen.length;this.t++){
gameSystem.tribeMen[this.t].k+=1;
if(gameSystem.tribeMen[this.t].k==gameSystem.tribeMen[this.t].keepMoveTime){
gameSystem.tribeMen[this.t].isChangeDirection=true;
gameSystem.tribeMen[this.t].k=0;
}else{
gameSystem.tribeMen[this.t].isChangeDirection=false;
}
}
//----------------end: about tribe man time control--------------------
//----------------start: about cowboy weak tip time control------------------
//控制牛仔进入虚弱期时每隔2秒中显示虚弱提示,显示2秒后隐藏
this.i++;
if(this.i > this.weakTipChangeTime){
if(this.i >= this.weakTipChangeTime + this.weakTipShowTime) this.i = 0;
westCowboy.isWeak=true;
}else
westCowboy.isWeak=false;
//----------------end: about cowboy weak tip time control-------------------
//----------------start: about blood bottle time control--------------------
//bottle 一开始就出现,显示指定时间,超过显示时间消失,进入下一回循环
this.j++;
if(this.j > this.bottleShowTime){ //show time
//hide bottle by 4 step
if(this.j == this.bottleShowTime+1) bloodBottle.bloodValue=Math.ceil(bloodBottle.bloodValue*0.6);
if(this.j == this.bottleShowTime+2) bloodBottle.bloodValue=Math.ceil(bloodBottle.bloodValue*0.5);
if(this.j == this.bottleShowTime+3) bloodBottle.bloodValue=Math.ceil(bloodBottle.bloodValue*0.2);
if(this.j > this.bottleShowTime+3) bloodBottle.bloodValue=0;
if(this.j >= this.newBottleTime + this.bottleShowTime+4){
this.j=1;
bloodBottle.init();
}
}
//----------------end: about blood bottle time control----------------------
}
};
//--------------------end: keep tribe move time define---------------
//--------------------start: generalTools object define----------------
var generalTools={
rangeRandom:function(minValue, maxValue){
if(maxValue >= minValue)
return Math.floor(Math.random()*(maxValue-minValue+1)+minValue);
else
return Math.floor(Math.random()*(minValue-maxValue+1)+maxValue);
},
rangeRandom2:function(minValue, maxValue,maxValuePercent){
//function to get value, maxValue [percent = maxValuePercent ], minValue [percent = 1-maxValuePercent ]
var mvPer=0;
var v=0;
try{ mvPer=parseFloat(maxValuePercent); }catch(e){ mvPer=0.2; }
if(Math.random()>=(1-mvPer))
v=maxValue;
else
v=minValue;
return v;
}
};
//--------------------end: generalTools object define-----------------
//---------------------start: west cowboy define---------------------
var westCowboy={
cowboyVersion:"1.0.0", //about the west Cowboy info and refered author
cowboyPicSRC : "man.png", //http://hi.csdn.net/attachment/201112/28/65387_1325068968P78Z.png
cowboyPicObj:"",
gridSize:50, //width=height=50
picSN:0,
cowboyPicAuthor : "shenzhenNBA",
initLifeValue: 5000,
lifeValue : 0,
killValue : 1,
speed : 1,
qspeed : 4,
x : 0,
y : 0,
innerXMin : 0,
innerYMin : 0,
innerXMax : 0,
innerYMax : 0,
r : 20, //cowboy size:20*20
isShowTip : false, //[show refered info, true=show, false=hide(default)]
isWeak : false,
//isEatBlood : false, //true=eat blood, false= no eat(default)
init: function(){
this.lifeValue=this.initLifeValue;
this.innerXMin=this.r;
this.innerYMin=this.r;
//this.innerXMax= gameSystem.scrW-this.r;
//this.innerYMax= gameSystem.scrH-this.r;
this.innerXMax=$("gameCanvas").width-this.gridSize*0.8;
this.innerYMax=$("gameCanvas").height-this.gridSize*0.8;
this.x=Math.floor($("gameCanvas").width/2);
this.y=Math.floor($("gameCanvas").height/2);
var img=new Image();
i