87,994
社区成员




<!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>Fighting - HTML5</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.0.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>, 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="cowboyPX">0</span>, Death:<span class="num02" id="cowboyPX">0</span>
control key: [ ↑,←, ↓, → ] or [ W,A,S,D ], fast + [ Ctrl ]
<a class="a01" href="javascript:gameStart();" title="开始">Start</a> <a class="a01" href="javascript:gamePause();" title="暂停">Pause</a> <a class="a01" href="javascript:gameContinue();" title="继续">Continue</a> <a class="a01" href="javascript:gameRestart();" title="结束当前重新开始游戏">Restart</a> <a class="a01" href="javascript:gameEnd();" title="结束游戏">End</a>
<a class="a01" title="游戏说明" href="javascript:void(0);">How to play</a> <span id="num">9</span>
</div>
</div>
<!--end: info panel-->
<script language="javascript" type="text/javascript">
//---------------------start: west cowboy define---------------------
var westCowboy={
cowboyVersion:"1.0.0", //about the west Cowboy info and refered author
cowboyPicSRC : "http://hi.csdn.net/attachment/201112/17/65387_1324102531Z4He.png", //man.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]
init: function(){
this.lifeValue=this.initLifeValue;
this.innerXMin=this.r;
this.innerYMin=this.r;
//this.innerXMax= sysVariables.scrW-this.r;
//this.innerYMax= sysVariables.scrH-this.r;
this.innerXMax=$("gameCanvas").width-this.r;
this.innerYMax=$("gameCanvas").height-this.r;
this.x=$("gameCanvas").width/2;
this.y=$("gameCanvas").height/2;
var img=new Image();
img.src=this.cowboyPicSRC;
this.cowboyPicObj=img;
}
};
westCowboy.getSpeed = function(){ //get move speed flag
return (inputFlag.quick ? this.qspeed : this.speed); //attend: this = westCowboy
};
westCowboy.showCowboyTip = function(){
//function to show cowboy refered information
if(this.isShowTip){
var c=$("gameCanvas");
var cxt=c.getContext("2d");
//cxt.clearRect(this.left+this.r,this.top+this.r,80,25); //clear area
cxt.font="10px Arial";
cxt.fillStyle="#6600FF"; //FF6600
cxt.fillText("Life:"+this.lifeValue,this.x+this.r*2,this.y+this.r);
}
};
westCowboy.move=function(){
if(this.lifeValue>0){
if (inputFlag.right)westCowboy.x+=westCowboy.getSpeed();
if (inputFlag.left) westCowboy.x-=westCowboy.getSpeed();
if (inputFlag.down) westCowboy.y+=westCowboy.getSpeed();
if (inputFlag.up) westCowboy.y-=westCowboy.getSpeed();
}
$("cowboyLife").innerHTML=westCowboy.lifeValue;
$("cowboyPX").innerHTML=westCowboy.x;
$("cowboyPY").innerHTML=westCowboy.y;
if (westCowboy.x > westCowboy.innerXMax) westCowboy.x=westCowboy.innerXMax;
//if (westCowboy.x<westCowboy.innerXMin) westCowboy.x=westCowboy.innerXMin;
if (westCowboy.x < westCowboy.r) westCowboy.x=westCowboy.innerXMin;
if (westCowboy.y > westCowboy.innerYMax) westCowboy.y=westCowboy.innerYMax;
//if (westCowboy.y<westCowboy.innerYMin) westCowboy.y=westCowboy.innerYMin;
if (westCowboy.y < westCowboy.r) westCowboy.y=westCowboy.innerYMin;
var c=$("gameCanvas");
var cxt=c.getContext("2d");
//format: drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh)
if(this.lifeValue>0){
if(inputFlag.left) //move to right
cxt.drawImage(westCowboy.cowboyPicObj,westCowboy.gridSize*westCowboy.picSN,westCowboy.gridSize*3,westCowboy.gridSize,westCowboy.gridSize,this.x,this.y,westCowboy.gridSize,westCowboy.gridSize);
else if(inputFlag.right) //move to left
cxt.drawImage(westCowboy.cowboyPicObj,westCowboy.gridSize*westCowboy.picSN,westCowboy.gridSize*4,westCowboy.gridSize,westCowboy.gridSize,this.x,this.y,westCowboy.gridSize,westCowboy.gridSize);
else //stop move
cxt.drawImage(westCowboy.cowboyPicObj,westCowboy.gridSize*3,westCowboy.gridSize*3,westCowboy.gridSize,westCowboy.gridSize,this.x,this.y,westCowboy.gridSize,westCowboy.gridSize);
westCowboy.picSN+=1;
if(westCowboy.picSN>=4) westCowboy.picSN=0;
}else{
cxt.drawImage(westCowboy.cowboyPicObj,westCowboy.gridSize*4,westCowboy.gridSize*3,westCowboy.gridSize,westCowboy.gridSize,this.x,this.y,westCowboy.gridSize,westCowboy.gridSize);
}
/* for TEST, ONLY draw a dot */
/*
cxt.fillStyle="#666666"; //draw the RED dot //, FF0000
cxt.beginPath();
cxt.arc(westCowboy.x,westCowboy.y,westCowboy.r,0,Math.PI * 2,true); //draw a dot; syntax: context.arc(centerX, centerY, radius, startingAngle, endingAngle, antiClockwise);
cxt.closePath();
cxt.fill();
*/
this.showCowboyTip();
};
westCowboy.eat= function(){
//function to eat blood when touch blood Bottle
}
//---------------------end: west cowboy define-----------------------