Сообщение от рони
|
что такое player.color?
|
объект плеер:
var player = {
level: 1,
hp: 3,
width: 50,
height: 50,
x: 320,
y: 240,
step: 2,
score: 0,
color: randomColor(),
draw: function () {
drawRect(this.x, this.y, this.width, this.height, this.color);
},
move: function () {
if (isKeyDown('UP')) {
this.y = Math.max(this.y - this.step, 0);
}
if (isKeyDown('DOWN')) {
this.y = Math.min(this.y + this.step, height - this.height);
}
if (isKeyDown('LEFT')) {
this.x = Math.max(this.x - this.step, 0);
}
if (isKeyDown('RIGHT')) {
this.x = Math.min(this.x + this.step, width - this.width);
}
},
init: function (x, y) {
this.x = x;
this.y = y;
},
collision: function () {
for (var i in target.nodes) {
var enemy = target.nodes[i];
if (isCollision(this.x, this.y, this.width, this.height, enemy.x, enemy.y, enemy.width, enemy.height)) {
target.destroy(i);
}
}
}
};