Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 1765 bytes modified
parent
483ddfdc0b
commit
c8c9a3b8d0
|
@ -205,7 +205,13 @@ GameLib.CustomCode.prototype.displayHUD = function() {
|
|||
this.canvasHUD.text('slow', 420, 500, '12px Pixeled', '#ffffff');
|
||||
|
||||
if (this.state.message) {
|
||||
this.canvasHUD.text(this.state.message, 220, 250, '30px Pixeled', '#ffffff');
|
||||
this.canvasHUD.text(
|
||||
this.state.message.text,
|
||||
this.state.message.x,
|
||||
this.state.message.y,
|
||||
'30px Pixeled',
|
||||
'#ffffff'
|
||||
);
|
||||
}
|
||||
|
||||
this.canvasHUD.image(this.imagePowerupSpeed.instance, 50, 460, 48, 48);
|
||||
|
@ -232,9 +238,7 @@ GameLib.CustomCode.prototype.waitReload = function(delta) {
|
|||
this.state.exploding = false;
|
||||
|
||||
if (this.state.lives <= 0) {
|
||||
this.state.gameOver = true;
|
||||
this.state.message = "GAME OVER";
|
||||
this.displayHUD();
|
||||
this.gameOver(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -254,7 +258,11 @@ GameLib.CustomCode.prototype.waitReload = function(delta) {
|
|||
|
||||
window.setTimeout(
|
||||
function(){
|
||||
this.state.message = "GO!";
|
||||
this.state.message = {
|
||||
text : "GO!",
|
||||
x : 150,
|
||||
y : 256
|
||||
};
|
||||
this.displayHUD();
|
||||
this.state.getReady = false;
|
||||
}.bind(this),
|
||||
|
@ -263,7 +271,11 @@ GameLib.CustomCode.prototype.waitReload = function(delta) {
|
|||
|
||||
window.setTimeout(
|
||||
function(){
|
||||
this.state.message = "1";
|
||||
this.state.message = {
|
||||
text: "1",
|
||||
x: 160,
|
||||
y: 256
|
||||
};
|
||||
this.displayHUD();
|
||||
}.bind(this),
|
||||
3000
|
||||
|
@ -271,7 +283,11 @@ GameLib.CustomCode.prototype.waitReload = function(delta) {
|
|||
|
||||
window.setTimeout(
|
||||
function(){
|
||||
this.state.message = "2";
|
||||
this.state.message = {
|
||||
text: "2",
|
||||
x: 160,
|
||||
y: 256
|
||||
};
|
||||
this.displayHUD();
|
||||
}.bind(this),
|
||||
2000
|
||||
|
@ -280,13 +296,21 @@ GameLib.CustomCode.prototype.waitReload = function(delta) {
|
|||
|
||||
window.setTimeout(
|
||||
function(){
|
||||
this.state.message = "3";
|
||||
this.state.message = {
|
||||
text: "3",
|
||||
x: 160,
|
||||
y: 256
|
||||
};
|
||||
this.displayHUD();
|
||||
}.bind(this),
|
||||
1000
|
||||
);
|
||||
|
||||
this.state.message = "READY?";
|
||||
this.state.message = {
|
||||
text: "GET READY",
|
||||
x: 100,
|
||||
y: 256
|
||||
};
|
||||
this.displayHUD();
|
||||
|
||||
}.bind(this)
|
||||
|
@ -438,16 +462,6 @@ GameLib.CustomCode.GameObject = function(
|
|||
this.position = position;
|
||||
}
|
||||
|
||||
/* GameLib.CustomCode.GameObject.prototype.clone = function() {
|
||||
|
||||
return new GameLib.CustomCode.GameObject(
|
||||
this.objectType,
|
||||
this.type,
|
||||
this.mesh,
|
||||
this.position
|
||||
)
|
||||
};
|
||||
*/
|
||||
/**
|
||||
* Disposes of the mesh object and resets this object to its defaults
|
||||
*/
|
||||
|
@ -513,6 +527,10 @@ GameLib.CustomCode.prototype.getFreeGridPosition = function() {
|
|||
}
|
||||
);
|
||||
|
||||
if (positions.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var index = GameLib.Utils.GetRandomInt(0, positions.length);
|
||||
|
||||
return positions[index];
|
||||
|
@ -755,12 +773,20 @@ GameLib.CustomCode.prototype.createPowerup = function(delta) {
|
|||
return;
|
||||
}
|
||||
|
||||
var position = this.getFreeGridPosition();
|
||||
|
||||
if (position === null) {
|
||||
this.gameOver(true);
|
||||
} else {
|
||||
|
||||
this.createGameObject(
|
||||
GameLib.CustomCode.OBJECT_TYPE_POWERUP,
|
||||
null,
|
||||
this.getFreeGridPosition()
|
||||
position
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}.bind(this);
|
||||
|
||||
GameLib.CustomCode.prototype.createFood = function(delta) {
|
||||
|
@ -777,14 +803,29 @@ GameLib.CustomCode.prototype.createFood = function(delta) {
|
|||
return;
|
||||
}
|
||||
|
||||
var position = this.getFreeGridPosition();
|
||||
|
||||
if (position === null) {
|
||||
this.gameOver(true);
|
||||
} else {
|
||||
this.createGameObject(
|
||||
GameLib.CustomCode.OBJECT_TYPE_FOOD,
|
||||
null,
|
||||
this.getFreeGridPosition()
|
||||
position
|
||||
);
|
||||
}
|
||||
|
||||
}.bind(this);
|
||||
|
||||
GameLib.CustomCode.prototype.gameOver = function(won) {
|
||||
this.state.gameOver = true;
|
||||
this.state.message = {
|
||||
text : "GAME OVER",
|
||||
x : 100,
|
||||
y : 256
|
||||
};
|
||||
this.displayHUD();
|
||||
}.bind(this)
|
||||
|
||||
/**
|
||||
* GameLib.CustomCode.SnakeBody
|
||||
|
@ -1102,6 +1143,10 @@ GameLib.CustomCode.prototype.extend = function(gameObject, position, orientation
|
|||
|
||||
this.grid[body.position.x][body.position.y] = body;
|
||||
|
||||
if (this.snake.length === GameLib.CustomCode.GRID_WIDTH * GameLib.CustomCode.GRID_HEIGHT) {
|
||||
this.gameOver(true);
|
||||
}
|
||||
|
||||
}.bind(this);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue