Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 1576 bytes modified
parent
02f897936f
commit
99355cf479
|
@ -17,7 +17,7 @@ GameLib.CustomCode.GRID_HEIGHT = 10;
|
||||||
GameLib.CustomCode.GRID_OFFSET_X = 1;
|
GameLib.CustomCode.GRID_OFFSET_X = 1;
|
||||||
GameLib.CustomCode.GRID_OFFSET_Y = 8;
|
GameLib.CustomCode.GRID_OFFSET_Y = 8;
|
||||||
|
|
||||||
GameLib.CustomCode.SPEED_INITIAL = 0.5;
|
GameLib.CustomCode.SPEED_INITIAL = 1;
|
||||||
|
|
||||||
GameLib.CustomCode.ORIENTATION_UP = 0;
|
GameLib.CustomCode.ORIENTATION_UP = 0;
|
||||||
GameLib.CustomCode.ORIENTATION_LEFT = 1;
|
GameLib.CustomCode.ORIENTATION_LEFT = 1;
|
||||||
|
@ -35,6 +35,14 @@ GameLib.CustomCode.POWERUP_LIFE = 1;
|
||||||
GameLib.CustomCode.POWERUP_SLOW = 2;
|
GameLib.CustomCode.POWERUP_SLOW = 2;
|
||||||
GameLib.CustomCode.MAX_POWERUP_ITEMS = 3;
|
GameLib.CustomCode.MAX_POWERUP_ITEMS = 3;
|
||||||
|
|
||||||
|
GameLib.CustomCode.SPEED_GRAIN = 0.1;
|
||||||
|
GameLib.CustomCode.MAX_SPEED = 0.3;
|
||||||
|
GameLib.CustomCode.MIN_SPEED = GameLib.CustomCode.SPEED_INITIAL;
|
||||||
|
|
||||||
|
GameLib.CustomCode.ANIMATION_SPEED_GRAIN = 0.2;
|
||||||
|
GameLib.CustomCode.MIN_ANIMATION_SPEED = 2;
|
||||||
|
GameLib.CustomCode.MAX_ANIMATION_SPEED = 10;
|
||||||
|
|
||||||
GameLib.CustomCode.FOOD_BACON = 0;
|
GameLib.CustomCode.FOOD_BACON = 0;
|
||||||
GameLib.CustomCode.FOOD_CHEESE = 1;
|
GameLib.CustomCode.FOOD_CHEESE = 1;
|
||||||
GameLib.CustomCode.FOOD_ONION = 2;
|
GameLib.CustomCode.FOOD_ONION = 2;
|
||||||
|
@ -1154,7 +1162,52 @@ GameLib.CustomCode.prototype.extend = function(gameObject, position, orientation
|
||||||
* @param gameObject
|
* @param gameObject
|
||||||
*/
|
*/
|
||||||
GameLib.CustomCode.prototype.powerup = function(gameObject) {
|
GameLib.CustomCode.prototype.powerup = function(gameObject) {
|
||||||
console.log('powerup');
|
|
||||||
|
if (gameObject.objectType !== GameLib.CustomCode.OBJECT_TYPE_POWERUP) {
|
||||||
|
throw new Error('wrong type of game object');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gameObject.type === GameLib.CustomCode.POWERUP_LIFE) {
|
||||||
|
|
||||||
|
this.lives += 1;
|
||||||
|
|
||||||
|
if (this.lives > 3) {
|
||||||
|
this.lives = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gameObject.type === GameLib.CustomCode.POWERUP_SPEED) {
|
||||||
|
|
||||||
|
this.speed -= GameLib.CustomCode.SPEED_GRAIN;
|
||||||
|
|
||||||
|
if (this.speed < GameLib.CustomCode.MAX_SPEED) {
|
||||||
|
this.speed = GameLib.CustomCode.MAX_SPEED;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.animation.translationSpeed += GameLib.CustomCode.ANIMATION_SPEED_GRAIN;
|
||||||
|
|
||||||
|
if (this.animation.translationSpeed > GameLib.CustomCode.MAX_ANIMATION_SPEED) {
|
||||||
|
this.animation.translationSpeed = GameLib.CustomCode.MAX_ANIMATION_SPEED;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gameObject.type === GameLib.CustomCode.POWERUP_SLOW) {
|
||||||
|
|
||||||
|
this.speed += GameLib.CustomCode.SPEED_GRAIN;
|
||||||
|
|
||||||
|
if (this.speed > GameLib.CustomCode.MIN_SPEED) {
|
||||||
|
this.speed = GameLib.CustomCode.MIN_SPEED;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.animation.translationSpeed -= GameLib.CustomCode.ANIMATION_SPEED_GRAIN;
|
||||||
|
|
||||||
|
if (this.animation.translationSpeed < GameLib.CustomCode.MIN_ANIMATION_SPEED) {
|
||||||
|
this.animation.translationSpeed = GameLib.CustomCode.MIN_ANIMATION_SPEED;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
this.powerups.splice(
|
this.powerups.splice(
|
||||||
this.powerups.indexOf(gameObject),
|
this.powerups.indexOf(gameObject),
|
||||||
|
|
Loading…
Reference in New Issue