|
@@ -59,7 +59,6 @@ const squareOne = {
|
|
|
button: undefined,
|
|
|
text: undefined,
|
|
|
};
|
|
|
-
|
|
|
this.control = {
|
|
|
direc: gameOperation == 'minus' ? -1 : 1,
|
|
|
divisorsList: '',
|
|
@@ -70,21 +69,21 @@ const squareOne = {
|
|
|
|
|
|
count: 0,
|
|
|
};
|
|
|
-
|
|
|
this.animation = {
|
|
|
animateTractor: false,
|
|
|
animateEnding: false,
|
|
|
speed: 2 * this.control.direc,
|
|
|
};
|
|
|
-
|
|
|
+ const truckWidth = 201;
|
|
|
this.default = {
|
|
|
- width: context.canvas.width / 11,
|
|
|
- height: 40 * 1.5,
|
|
|
+ width: 172,
|
|
|
+ height: 70,
|
|
|
x0:
|
|
|
- gameOperation == 'minus' ? context.canvas.width - 170 * 1.5 : 170 * 1.5,
|
|
|
- y0: context.canvas.height - 157 * 1.5 + 10,
|
|
|
+ gameOperation == 'minus'
|
|
|
+ ? context.canvas.width - truckWidth
|
|
|
+ : truckWidth,
|
|
|
+ y0: context.canvas.height - game.image['floor_grass'].width * 1.5,
|
|
|
};
|
|
|
-
|
|
|
renderBackground();
|
|
|
|
|
|
|
|
@@ -124,34 +123,6 @@ const squareOne = {
|
|
|
},
|
|
|
};
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
let lineColor = undefined;
|
|
|
let fillColor = undefined;
|
|
|
if (gameOperation === 'minus') {
|
|
@@ -161,6 +132,7 @@ const squareOne = {
|
|
|
lineColor = colors.green;
|
|
|
fillColor = colors.greenLight;
|
|
|
}
|
|
|
+
|
|
|
this.restart = this.utils.renderStackedBlocks(
|
|
|
this.control.direc,
|
|
|
lineColor,
|
|
@@ -217,7 +189,7 @@ const squareOne = {
|
|
|
|
|
|
self.blocks.floor.correctXA =
|
|
|
self.default.x0 + self.default.width * direc;
|
|
|
-
|
|
|
+ console.log('-->' + self.blocks.floor.correctXA);
|
|
|
for (let i = 0; i < total; i++) {
|
|
|
let curFractionItems = undefined;
|
|
|
let font = undefined;
|
|
@@ -227,13 +199,13 @@ const squareOne = {
|
|
|
if (curDivisor === 3) curDivisor = 4;
|
|
|
|
|
|
const curBlockWidth = self.default.width / curDivisor;
|
|
|
-
|
|
|
self.control.divisorsList += curDivisor + ',';
|
|
|
self.blocks.floor.correctXA += curBlockWidth * direc;
|
|
|
+ console.log('->' + self.blocks.floor.correctXA);
|
|
|
|
|
|
const curBlock = game.add.geom.rect(
|
|
|
self.default.x0,
|
|
|
- self.default.y0 + 17 - i * (self.default.height - lineSize),
|
|
|
+ self.default.y0 - i * (self.default.height - lineSize),
|
|
|
curBlockWidth - lineSize,
|
|
|
self.default.height - lineSize,
|
|
|
lineColor,
|
|
@@ -241,7 +213,7 @@ const squareOne = {
|
|
|
fillColor,
|
|
|
1
|
|
|
);
|
|
|
- curBlock.anchor(gameOperation === 'minus' ? 1 : 0, 0);
|
|
|
+ curBlock.anchor(gameOperation === 'minus' ? 1 : 0, 1);
|
|
|
|
|
|
|
|
|
if (gameMode == 'b') {
|
|
@@ -261,7 +233,7 @@ const squareOne = {
|
|
|
curFractionItems = [
|
|
|
{
|
|
|
x: x,
|
|
|
- y: self.default.y0 - (i - 1) * y,
|
|
|
+ y: self.default.y0 - i * y - 20,
|
|
|
text: gameOperation === 'minus' ? '-1' : '1',
|
|
|
},
|
|
|
];
|
|
@@ -270,22 +242,22 @@ const squareOne = {
|
|
|
curFractionItems = [
|
|
|
{
|
|
|
x: x,
|
|
|
- y: self.default.y0 + 45 - i * y + 23,
|
|
|
+ y: self.default.y0 - i * y - 10,
|
|
|
text: curDivisor,
|
|
|
},
|
|
|
{
|
|
|
x: x,
|
|
|
- y: self.default.y0 + 40 - i * y,
|
|
|
+ y: self.default.y0 - i * y - 40,
|
|
|
text: '1',
|
|
|
},
|
|
|
{
|
|
|
x: x,
|
|
|
- y: self.default.y0 + 40 - i * y,
|
|
|
+ y: self.default.y0 - i * y - 37,
|
|
|
text: '__',
|
|
|
},
|
|
|
{
|
|
|
- x: x - 25,
|
|
|
- y: self.default.y0 + 40 + 10 - i * y,
|
|
|
+ x: x - 25,
|
|
|
+ y: self.default.y0 - i * y - 27,
|
|
|
text: gameOperation === 'minus' ? '-' : '',
|
|
|
},
|
|
|
];
|
|
@@ -344,6 +316,8 @@ const squareOne = {
|
|
|
* Create floor blocks for the level in create()
|
|
|
*/
|
|
|
renderFloorBlocks: function (direc, lineColor) {
|
|
|
+ const lineSize = 2;
|
|
|
+
|
|
|
|
|
|
const divisor = gameDifficulty == 3 ? 4 : gameDifficulty;
|
|
|
|
|
@@ -370,25 +344,24 @@ const squareOne = {
|
|
|
let flag = true;
|
|
|
|
|
|
for (let i = 0; i < total; i++) {
|
|
|
-
|
|
|
-
|
|
|
- const x =
|
|
|
- self.default.x0 + (self.default.width + i * blockWidth) * direc;
|
|
|
-
|
|
|
+ const curX =
|
|
|
+ self.default.x0 + (self.default.width + i * blockWidth) * direc;
|
|
|
+ console.log(curX, self.blocks.floor.correctXA, '.');
|
|
|
if (flag && gameMode == 'a') {
|
|
|
if (
|
|
|
- (gameOperation == 'plus' && x >= self.blocks.floor.correctXA) ||
|
|
|
- (gameOperation == 'minus' && x <= self.blocks.floor.correctXA)
|
|
|
+ (gameOperation == 'plus' && curX >= self.blocks.floor.correctXA) ||
|
|
|
+ (gameOperation == 'minus' && curX <= self.blocks.floor.correctXA)
|
|
|
) {
|
|
|
self.blocks.floor.correctIndex = i - 1;
|
|
|
flag = false;
|
|
|
+ console.log(self.blocks.floor.correctIndex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (gameMode == 'b') {
|
|
|
if (
|
|
|
- (gameOperation == 'plus' && x >= self.blocks.floor.correctXB) ||
|
|
|
- (gameOperation == 'minus' && x <= self.blocks.floor.correctXB)
|
|
|
+ (gameOperation == 'plus' && curX >= self.blocks.floor.correctXB) ||
|
|
|
+ (gameOperation == 'minus' && curX <= self.blocks.floor.correctXB)
|
|
|
) {
|
|
|
total = i;
|
|
|
break;
|
|
@@ -396,28 +369,27 @@ const squareOne = {
|
|
|
}
|
|
|
|
|
|
|
|
|
- const lineSize = 0.9;
|
|
|
- const block = game.add.geom.rect(
|
|
|
- x,
|
|
|
- self.default.y0 + 17 + self.default.height - lineSize,
|
|
|
+ const curBlock = game.add.geom.rect(
|
|
|
+ curX,
|
|
|
+ self.default.y0 - lineSize,
|
|
|
blockWidth - lineSize,
|
|
|
self.default.height - lineSize,
|
|
|
- colors.blue,
|
|
|
+ lineColor,
|
|
|
lineSize,
|
|
|
colors.blueBgInsideLevel,
|
|
|
1
|
|
|
);
|
|
|
const anchor = gameOperation == 'minus' ? 1 : 0;
|
|
|
- block.anchor(anchor, 0);
|
|
|
+ curBlock.anchor(anchor, 0);
|
|
|
|
|
|
|
|
|
if (gameMode == 'a') {
|
|
|
- block.alpha = 0.5;
|
|
|
- block.index = i;
|
|
|
+ curBlock.alpha = 0.5;
|
|
|
+ curBlock.index = i;
|
|
|
}
|
|
|
|
|
|
|
|
|
- self.blocks.floor.list.push(block);
|
|
|
+ self.blocks.floor.list.push(curBlock);
|
|
|
}
|
|
|
|
|
|
if (gameMode == 'a')
|
|
@@ -428,7 +400,7 @@ const squareOne = {
|
|
|
|
|
|
for (let i = 0; i <= 8; i++) {
|
|
|
const x = self.default.x0 + (i + 1) * self.default.width * direc;
|
|
|
- const y = self.default.y0 + self.default.height + 80 * 1.5;
|
|
|
+ const y = self.default.y0 + self.default.height + 45;
|
|
|
game.add.geom
|
|
|
.circle(x, y, 60, undefined, 0, colors.white, 0.6)
|
|
|
.anchor(0, 0.25);
|
|
@@ -450,14 +422,14 @@ const squareOne = {
|
|
|
self.default.y0,
|
|
|
'tractor',
|
|
|
0,
|
|
|
- 1.2
|
|
|
+ 1
|
|
|
);
|
|
|
|
|
|
if (gameOperation == 'plus') {
|
|
|
- self.tractor.anchor(1, 0.5);
|
|
|
+ self.tractor.anchor(1, 1);
|
|
|
self.tractor.animation = ['move', [0, 1, 2, 3, 4], 4];
|
|
|
} else {
|
|
|
- self.tractor.anchor(0, 0.5);
|
|
|
+ self.tractor.anchor(0, 1);
|
|
|
self.tractor.animation = ['move', [5, 6, 7, 8, 9], 4];
|
|
|
self.tractor.curFrame = 5;
|
|
|
}
|
|
@@ -536,10 +508,8 @@ const squareOne = {
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
self.tractor.x += self.animation.speed;
|
|
|
-
|
|
|
-
|
|
|
for (let i in stack.list) {
|
|
|
stack.list[i].x += self.animation.speed;
|
|
|
}
|
|
@@ -596,7 +566,7 @@ const squareOne = {
|
|
|
(gameOperation == 'plus' && floor.list[i].x < curEnd) ||
|
|
|
(gameOperation == 'minus' && floor.list[i].x > curEnd)
|
|
|
) {
|
|
|
- floor.list[i].alpha = 0.2;
|
|
|
+ floor.list[i].alpha = 0;
|
|
|
floor.curIndex = i;
|
|
|
}
|
|
|
}
|
|
@@ -625,6 +595,7 @@ const squareOne = {
|
|
|
if (gameMode == 'a') {
|
|
|
self.control.isCorrect =
|
|
|
self.blocks.floor.index == self.blocks.floor.correctIndex;
|
|
|
+ console.log(self.blocks.floor.index, self.blocks.floor.correctIndex);
|
|
|
} else {
|
|
|
self.control.isCorrect =
|
|
|
self.blocks.stack.index == self.blocks.stack.correctIndex;
|