全部在一个文件中
它是 html5/javascript 画布游戏的开始
似乎每个人的独奏都在更好地链接库(这都是一个文件)或在创建对象时添加新的(我这样做了)
没有对象,代码可以正常工作:/
缩写代码
html codes
codes
var tempa = new asteroid(BASIC_L, 100, 300,300,0,0,2,2,0,0);
codes
function asteroid(type, hp, x, y, z, r, vx, vy, vz, vr)
{
this.type = type;
this.hp = hp;
this.x = x;
this.y = y;
this.z = z;
this.r = r;
this.vx = vx;
this.vy = vy;
this.vz = vz;
this.vr = vr;
function display(){
this.x += this.vx;
this.y += this.vy;
if(this.type == BASIC_L){
debug(this.type);
ctx.beginPath();
ctx.strokeStyle="#00fff0";
ctx.arc(this.x,this.y,100,0,2*Math.PI);
ctx.stroke();
}
}
}
//codes
function draw(){
//codes
tempa.display();
}
//codes
//html codes