Add: God's next chocoball
This commit is contained in:
@@ -32,6 +32,7 @@ var Game = {
|
||||
|
||||
// init game elements
|
||||
this.initVariables();
|
||||
this.drawObjects();
|
||||
|
||||
|
||||
// bottom ui
|
||||
@@ -46,9 +47,13 @@ var Game = {
|
||||
},
|
||||
|
||||
initVariables: function() {
|
||||
this.nextNumber = 1;
|
||||
|
||||
this.firstChocoballArray = this.makeChocoballArray(1, 25);
|
||||
this.secondChocoballArray = this.makeChocoballArray(26, 50);
|
||||
},
|
||||
|
||||
drawObjects: function() {
|
||||
this.chocoballs = new Array();
|
||||
for(var i = 0; i < 25; i++) {
|
||||
var chocoball = new Chocoball(
|
||||
@@ -59,9 +64,39 @@ var Game = {
|
||||
this.chocoballs.push(chocoball);
|
||||
}
|
||||
|
||||
this.god = new God(game.world.width - 120, Game.GOD_POSITION_Y + 100, this);
|
||||
var graphics = game.add.graphics(0, 0);
|
||||
var triangleStartX = God.POSITION_X;
|
||||
var triangleStartY = God.POSITION_Y - 220;
|
||||
var triangleHalfWidth = 20;
|
||||
var triangleHeight = 40;
|
||||
graphics.beginFill(0xFFFFFF);
|
||||
graphics.lineStyle(20, 0x000000);
|
||||
graphics.moveTo(triangleStartX, triangleStartY);
|
||||
graphics.lineTo(triangleStartX + triangleHalfWidth, triangleStartY - triangleHeight);
|
||||
graphics.lineTo(triangleStartX - triangleHalfWidth, triangleStartY - triangleHeight);
|
||||
graphics.lineTo(triangleStartX, triangleStartY);
|
||||
graphics.endFill();
|
||||
|
||||
this.nextNumber = 1;
|
||||
graphics.lineStyle(10, 0x000000);
|
||||
graphics.beginFill(0xFFFFFF);
|
||||
graphics.drawCircle(God.POSITION_X, God.POSITION_Y - 340, 200);
|
||||
graphics.endFill();
|
||||
|
||||
graphics.beginFill(0xFFFFFF);
|
||||
graphics.lineStyle(0);
|
||||
graphics.moveTo(triangleStartX, triangleStartY);
|
||||
graphics.lineTo(triangleStartX + triangleHalfWidth, triangleStartY - triangleHeight);
|
||||
graphics.lineTo(triangleStartX - triangleHalfWidth, triangleStartY - triangleHeight);
|
||||
graphics.lineTo(triangleStartX, triangleStartY);
|
||||
graphics.endFill();
|
||||
|
||||
this.nextChocoball = new Chocoball(
|
||||
100,
|
||||
(function(chocoball) { console.log("no event") }).bind(this)
|
||||
);
|
||||
this.nextChocoball.setNumber(this.nextNumber);
|
||||
|
||||
this.god = new God(God.POSITION_X, God.POSITION_Y, this);
|
||||
},
|
||||
|
||||
makeChocoballArray(firstNumber, lastNumber) {
|
||||
@@ -87,17 +122,21 @@ var Game = {
|
||||
if(chocoball.number == 1)
|
||||
this.stopWatch.start();
|
||||
|
||||
if(chocoball.number != this.nextNumber) {
|
||||
console.log("wrong");
|
||||
return;
|
||||
} else {
|
||||
if(chocoball.number == this.nextNumber) {
|
||||
this.nextNumber++;
|
||||
this.god.animateHappy();
|
||||
} else {
|
||||
console.log("wrong");
|
||||
this.god.animateAngry();
|
||||
return;
|
||||
}
|
||||
|
||||
if(chocoball.number < 25)
|
||||
if(chocoball.number < 25) {
|
||||
chocoball.setNumber(this.secondChocoballArray[chocoball.index]);
|
||||
else
|
||||
this.nextChocoball.setNumber(this.nextNumber);
|
||||
} else {
|
||||
chocoball.setActive(false);
|
||||
}
|
||||
|
||||
if(chocoball.number == 50) {
|
||||
console.log("game clear");
|
||||
|
||||
Reference in New Issue
Block a user