|
@@ -1,9 +1,9 @@
|
|
-
|
|
|
|
/*
|
|
/*
|
|
|
|
+
|
|
var menuSquareOne = {
|
|
var menuSquareOne = {
|
|
create: function(){},
|
|
create: function(){},
|
|
---------------------------- end of phaser functions
|
|
---------------------------- end of phaser functions
|
|
- loadMap: function(){}
|
|
|
|
|
|
+ func_loadMap: function(){}
|
|
};
|
|
};
|
|
|
|
|
|
var mapSquareOne = {
|
|
var mapSquareOne = {
|
|
@@ -17,50 +17,47 @@
|
|
create: function(){},
|
|
create: function(){},
|
|
update: function(){},
|
|
update: function(){},
|
|
---------------------------- end of phaser functions
|
|
---------------------------- end of phaser functions
|
|
- updateCounter: function(){},
|
|
|
|
- overSquare: function(){},
|
|
|
|
- outSquare: function(){},
|
|
|
|
- clickSquare: function(){},
|
|
|
|
- //setPlace: function(){},
|
|
|
|
- postScore: function(){},
|
|
|
|
- viewHelp: function(){},
|
|
|
|
- //checkOverlap: function(){}
|
|
|
|
- //getRndDivisor: function(){}
|
|
|
|
|
|
+ func_updateCounter: function(){},
|
|
|
|
+ func_overSquare: function(){},
|
|
|
|
+ func_outSquare: function(){},
|
|
|
|
+ func_clickSquare: function(){},
|
|
|
|
+ //func_setPlace: function(){},
|
|
|
|
+ func_postScore: function(){},
|
|
|
|
+ func_viewHelp: function(){},
|
|
|
|
+ //func_checkOverlap: function(){}
|
|
|
|
+ //func_getRndDivisor: function(){}
|
|
};
|
|
};
|
|
|
|
|
|
var endSquareOne = {
|
|
var endSquareOne = {
|
|
create: function(){},
|
|
create: function(){},
|
|
update: function(){},
|
|
update: function(){},
|
|
---------------------------- end of phaser functions
|
|
---------------------------- end of phaser functions
|
|
- verPrincipal: function(){},
|
|
|
|
- verMenu: function(){}
|
|
|
|
|
|
+ func_verPrincipal: function(){},
|
|
};
|
|
};
|
|
|
|
+
|
|
*/
|
|
*/
|
|
|
|
|
|
// Tractor and Square states
|
|
// Tractor and Square states
|
|
|
|
|
|
/****************************** MENU ****************************/
|
|
/****************************** MENU ****************************/
|
|
-var stairsRight, stairsLeft;
|
|
|
|
|
|
|
|
var menuSquareOne = {
|
|
var menuSquareOne = {
|
|
|
|
|
|
create: function() {
|
|
create: function() {
|
|
-
|
|
|
|
- // Creating sound variable
|
|
|
|
- var beepSound = game.add.audio('sound_beep');
|
|
|
|
|
|
|
|
- // Menu options
|
|
|
|
- buttonSettings["addButtons"](1,1,
|
|
|
|
|
|
+ // Navigation buttons
|
|
|
|
+ buttonSettings["func_addButtons"](1,1,
|
|
0,1,0,
|
|
0,1,0,
|
|
1,0,
|
|
1,0,
|
|
0,0);
|
|
0,0);
|
|
|
|
|
|
- // Setting title
|
|
|
|
|
|
+ // Title
|
|
var style = { font: '28px Arial', fill: '#00804d'};
|
|
var style = { font: '28px Arial', fill: '#00804d'};
|
|
var title = game.add.text(game.world.centerX, 40, lang.game_menu_title, style);
|
|
var title = game.add.text(game.world.centerX, 40, lang.game_menu_title, style);
|
|
title.anchor.setTo(0.5, 0.5);
|
|
title.anchor.setTo(0.5, 0.5);
|
|
|
|
|
|
- //Showing Games and Levels
|
|
|
|
|
|
+ //SETTING DIFFICULTY LEVELS
|
|
|
|
+
|
|
var maxHeight = 120; //Max height of a stair
|
|
var maxHeight = 120; //Max height of a stair
|
|
var stairHeight = 40; //height growth of a stair
|
|
var stairHeight = 40; //height growth of a stair
|
|
var stairWidth = 100; //Width of a stair
|
|
var stairWidth = 100; //Width of a stair
|
|
@@ -68,26 +65,28 @@ var menuSquareOne = {
|
|
var startSymbol = 180;
|
|
var startSymbol = 180;
|
|
var startSquare = (startSymbol/2)+startStair+stairWidth*3;
|
|
var startSquare = (startSymbol/2)+startStair+stairWidth*3;
|
|
|
|
|
|
- //First stairs, plus, 3 levels, blue square
|
|
|
|
|
|
+ //First stairs, plus, 3 levels, blue square
|
|
|
|
+
|
|
var blueSquare = game.add.graphics(startSquare, 175);
|
|
var blueSquare = game.add.graphics(startSquare, 175);
|
|
blueSquare.anchor.setTo(0.5,0.5);
|
|
blueSquare.anchor.setTo(0.5,0.5);
|
|
blueSquare.lineStyle(2, 0x31314e);
|
|
blueSquare.lineStyle(2, 0x31314e);
|
|
blueSquare.beginFill(0xefeff5);
|
|
blueSquare.beginFill(0xefeff5);
|
|
blueSquare.drawRect(0, 0, 80, 40);
|
|
blueSquare.drawRect(0, 0, 80, 40);
|
|
blueSquare.endFill();
|
|
blueSquare.endFill();
|
|
- var bplus = game.add.sprite(startSymbol+30, 215, 'tractor_green');
|
|
|
|
- //bplus.frame = 0;
|
|
|
|
- bplus.scale.setTo(0.5);
|
|
|
|
- bplus.alpha = 0.9;
|
|
|
|
- bplus.anchor.setTo(0.5,0.5);
|
|
|
|
|
|
|
|
- var bplus2 = game.add.sprite(startSymbol+100, 215, 'h_arrow');
|
|
|
|
- bplus2.scale.setTo(0.3);
|
|
|
|
- bplus2.alpha = 0.9;
|
|
|
|
- bplus2.anchor.setTo(0.5,0.5);
|
|
|
|
|
|
+ var plusTractorIcon = game.add.sprite(startSymbol+30, 215, 'tractor_green');
|
|
|
|
+ //plus_tractor.frame = 0;
|
|
|
|
+ plusTractorIcon.scale.setTo(0.5);
|
|
|
|
+ plusTractorIcon.alpha = 0.9;
|
|
|
|
+ plusTractorIcon.anchor.setTo(0.5,0.5);
|
|
|
|
+
|
|
|
|
+ var plusArrowIcon = game.add.sprite(startSymbol+100, 215, 'h_arrow');
|
|
|
|
+ plusArrowIcon.scale.setTo(0.3);
|
|
|
|
+ plusArrowIcon.alpha = 0.9;
|
|
|
|
+ plusArrowIcon.anchor.setTo(0.5,0.5);
|
|
|
|
|
|
-
|
|
|
|
var stairsPlus = [];
|
|
var stairsPlus = [];
|
|
|
|
+
|
|
for(var i=1;i<=3;i++){
|
|
for(var i=1;i<=3;i++){
|
|
//stair
|
|
//stair
|
|
var x1 = startStair+(stairWidth*(i-1));
|
|
var x1 = startStair+(stairWidth*(i-1));
|
|
@@ -104,9 +103,10 @@ var menuSquareOne = {
|
|
//event
|
|
//event
|
|
stairsPlus[i].inputEnabled = true;
|
|
stairsPlus[i].inputEnabled = true;
|
|
stairsPlus[i].input.useHandCursor = true;
|
|
stairsPlus[i].input.useHandCursor = true;
|
|
- stairsPlus[i].events.onInputDown.add(this.loadMap, {beep: beepSound, difficulty: i, operator: 'Plus' });
|
|
|
|
|
|
+ stairsPlus[i].events.onInputDown.add(this.func_loadMap, {beep: beepSound, difficulty: i, operator: 'Plus' });
|
|
stairsPlus[i].events.onInputOver.add(function (item) { item.alpha=0.5; }, this);
|
|
stairsPlus[i].events.onInputOver.add(function (item) { item.alpha=0.5; }, this);
|
|
stairsPlus[i].events.onInputOut.add(function (item) { item.alpha=1; }, this);
|
|
stairsPlus[i].events.onInputOut.add(function (item) { item.alpha=1; }, this);
|
|
|
|
+
|
|
//label
|
|
//label
|
|
var xl = x1+stairWidth/2; //x label
|
|
var xl = x1+stairWidth/2; //x label
|
|
var yl = y1+(stairHeight*i)/2; //y label
|
|
var yl = y1+(stairHeight*i)/2; //y label
|
|
@@ -114,28 +114,29 @@ var menuSquareOne = {
|
|
label.anchor.setTo(0.5, 0.4);
|
|
label.anchor.setTo(0.5, 0.4);
|
|
}
|
|
}
|
|
|
|
|
|
- //Second stairs, minus, 5 levels, red Square
|
|
|
|
|
|
+ //Second stairs, minus, 3 levels, red Square
|
|
|
|
+
|
|
var redSquare = game.add.graphics(startSquare, 330);
|
|
var redSquare = game.add.graphics(startSquare, 330);
|
|
redSquare.anchor.setTo(0.5,0.5);
|
|
redSquare.anchor.setTo(0.5,0.5);
|
|
redSquare.lineStyle(2, 0xb30000);
|
|
redSquare.lineStyle(2, 0xb30000);
|
|
redSquare.beginFill(0xefeff5);
|
|
redSquare.beginFill(0xefeff5);
|
|
redSquare.drawRect(0, 0, 80, 40);
|
|
redSquare.drawRect(0, 0, 80, 40);
|
|
redSquare.endFill();
|
|
redSquare.endFill();
|
|
- var rminus = game.add.sprite(startSymbol+70, 370, 'tractor_red');
|
|
|
|
- //rminus.frame = 5;
|
|
|
|
- rminus.scale.setTo(0.5);
|
|
|
|
- rminus.alpha = 0.9;
|
|
|
|
- //rminus.scale.x *= -1;
|
|
|
|
- rminus.anchor.setTo(0.5,0.5);
|
|
|
|
|
|
+
|
|
|
|
+ var minusTractorIcon = game.add.sprite(startSymbol+70, 370, 'tractor_red');
|
|
|
|
+ //minusTractorIcon.frame = 5;
|
|
|
|
+ minusTractorIcon.scale.setTo(0.5);
|
|
|
|
+ minusTractorIcon.alpha = 0.9;
|
|
|
|
+ minusTractorIcon.anchor.setTo(0.5,0.5);
|
|
|
|
|
|
- var rminus2 = game.add.sprite(startSymbol, 370, 'h_arrow');
|
|
|
|
- rminus2.scale.setTo(0.3);
|
|
|
|
- rminus2.alpha = 0.9;
|
|
|
|
- rminus2.scale.x *= -1;
|
|
|
|
- rminus2.anchor.setTo(0.5,0.5);
|
|
|
|
|
|
+ var minusArrowIcon = game.add.sprite(startSymbol, 370, 'h_arrow');
|
|
|
|
+ minusArrowIcon.scale.setTo(0.3);
|
|
|
|
+ minusArrowIcon.alpha = 0.9;
|
|
|
|
+ minusArrowIcon.scale.x *= -1;
|
|
|
|
+ minusArrowIcon.anchor.setTo(0.5,0.5);
|
|
|
|
|
|
-
|
|
|
|
var stairsMinus = [];
|
|
var stairsMinus = [];
|
|
|
|
+
|
|
for(var i=1;i<=3;i++){
|
|
for(var i=1;i<=3;i++){
|
|
//stair
|
|
//stair
|
|
var x1 = startStair+(stairWidth*(i-1));
|
|
var x1 = startStair+(stairWidth*(i-1));
|
|
@@ -152,31 +153,33 @@ var menuSquareOne = {
|
|
//event
|
|
//event
|
|
stairsMinus[i].inputEnabled = true;
|
|
stairsMinus[i].inputEnabled = true;
|
|
stairsMinus[i].input.useHandCursor = true;
|
|
stairsMinus[i].input.useHandCursor = true;
|
|
- stairsMinus[i].events.onInputDown.add(this.loadMap, {beep: beepSound, difficulty: i, operator: 'Minus' });
|
|
|
|
|
|
+ stairsMinus[i].events.onInputDown.add(this.func_loadMap, {beep: beepSound, difficulty: i, operator: 'Minus' });
|
|
stairsMinus[i].events.onInputOver.add(function (item) { item.alpha=0.5; }, this);
|
|
stairsMinus[i].events.onInputOver.add(function (item) { item.alpha=0.5; }, this);
|
|
stairsMinus[i].events.onInputOut.add(function (item) { item.alpha=1; }, this);
|
|
stairsMinus[i].events.onInputOut.add(function (item) { item.alpha=1; }, this);
|
|
|
|
+
|
|
//label
|
|
//label
|
|
var xl = x1+stairWidth/2; //x label
|
|
var xl = x1+stairWidth/2; //x label
|
|
var yl = y1+(stairHeight*i)/2; //y label
|
|
var yl = y1+(stairHeight*i)/2; //y label
|
|
var label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' });
|
|
var label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' });
|
|
label.anchor.setTo(0.5, 0.4);
|
|
label.anchor.setTo(0.5, 0.4);
|
|
}
|
|
}
|
|
|
|
+
|
|
},
|
|
},
|
|
|
|
|
|
//MapLoading function
|
|
//MapLoading function
|
|
- loadMap: function(){
|
|
|
|
|
|
+ func_loadMap: function(){
|
|
|
|
+
|
|
if(audioStatus){
|
|
if(audioStatus){
|
|
this.beep.play();
|
|
this.beep.play();
|
|
}
|
|
}
|
|
- onePosition = 0; //Map position
|
|
|
|
- oneMove = true; //Move no next point
|
|
|
|
- oneDifficulty = this.difficulty; //Number of difficulty (1 to 5)
|
|
|
|
- oneOperator = this.operator; //Operator of game
|
|
|
|
- if(onePosition<5){
|
|
|
|
- game.state.start('mapSOne');
|
|
|
|
- }else{
|
|
|
|
- game.state.start('unofinal');
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ levelPosition = 0; //Map position
|
|
|
|
+ levelMove = true; //Move no next point
|
|
|
|
+ levelDifficulty = this.difficulty; //Number of difficulty (1 to 3)
|
|
|
|
+ levelOperator = this.operator; //Operator of game
|
|
|
|
+
|
|
|
|
+ game.state.start('mapSOne');
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
};
|
|
};
|
|
@@ -187,14 +190,11 @@ var mapSquareOne = {
|
|
|
|
|
|
create: function() {
|
|
create: function() {
|
|
|
|
|
|
- // Creating sound variable
|
|
|
|
- beepSound = game.add.audio('sound_beep');
|
|
|
|
-
|
|
|
|
// Background
|
|
// Background
|
|
game.add.image(0, 40, 'bgmap');
|
|
game.add.image(0, 40, 'bgmap');
|
|
|
|
|
|
- // Menu options
|
|
|
|
- buttonSettings["addButtons"](1,0,
|
|
|
|
|
|
+ // Navigation buttons
|
|
|
|
+ buttonSettings["func_addButtons"](1,0,
|
|
1,1,0,
|
|
1,1,0,
|
|
0,0,
|
|
0,0,
|
|
"menuSOne",0);
|
|
"menuSOne",0);
|
|
@@ -204,17 +204,18 @@ var mapSquareOne = {
|
|
var styleMenu = { font: '30px Arial', fill: '#000000', align: 'center'};
|
|
var styleMenu = { font: '30px Arial', fill: '#000000', align: 'center'};
|
|
|
|
|
|
// Progress bar
|
|
// Progress bar
|
|
- var percentText = onePosition*20;
|
|
|
|
- var percentBlocks = onePosition;
|
|
|
|
- for(var p=1;p<=percentBlocks;p++){
|
|
|
|
- var block = game.add.image(660+(p-1)*30, 10, 'block');
|
|
|
|
- block.scale.setTo(2, 1); //Scaling to double width
|
|
|
|
|
|
+ var percentText = passedLevels*25;
|
|
|
|
+ var percentBlocks = passedLevels;
|
|
|
|
+
|
|
|
|
+ for(var p=0;p<percentBlocks;p++){
|
|
|
|
+ var block = game.add.image(660+p*30, 10, 'block');
|
|
|
|
+ block.scale.setTo(3.75, 1); //Scaling to double width
|
|
}
|
|
}
|
|
game.add.text(820, 10, percentText+'%', styleMenu);
|
|
game.add.text(820, 10, percentText+'%', styleMenu);
|
|
- game.add.text(650, 10, lang.difficulty + ' ' + oneDifficulty, styleMenu).anchor.setTo(1,0);
|
|
|
|
|
|
+ game.add.text(650, 10, lang.difficulty + ' ' + levelDifficulty, styleMenu).anchor.setTo(1,0);
|
|
game.add.image(660, 10, 'pgbar');
|
|
game.add.image(660, 10, 'pgbar');
|
|
|
|
|
|
- //Road
|
|
|
|
|
|
+ //Road
|
|
this.points = {
|
|
this.points = {
|
|
'x': [ 90, 204, 318, 432, 546, 660 ],
|
|
'x': [ 90, 204, 318, 432, 546, 660 ],
|
|
'y': [ 486, 422, 358, 294, 230, 166 ]
|
|
'y': [ 486, 422, 358, 294, 230, 166 ]
|
|
@@ -259,13 +260,12 @@ var mapSquareOne = {
|
|
sprite.anchor.setTo(0.5, 0.95);
|
|
sprite.anchor.setTo(0.5, 0.95);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
// places
|
|
// places
|
|
for (var p = 1; p < this.points.x.length -1; p++){
|
|
for (var p = 1; p < this.points.x.length -1; p++){
|
|
var place;
|
|
var place;
|
|
- if(p<onePosition)
|
|
|
|
|
|
+ if(p<levelPosition)
|
|
place = game.add.image(this.points.x[p], this.points.y[p], 'place_b');
|
|
place = game.add.image(this.points.x[p], this.points.y[p], 'place_b');
|
|
- else if (oneMove && p==onePosition)
|
|
|
|
|
|
+ else if (levelMove && p==levelPosition)
|
|
place = game.add.image(this.points.x[p], this.points.y[p], 'place_b');
|
|
place = game.add.image(this.points.x[p], this.points.y[p], 'place_b');
|
|
else
|
|
else
|
|
place = game.add.image(this.points.x[p], this.points.y[p], 'place_a');
|
|
place = game.add.image(this.points.x[p], this.points.y[p], 'place_a');
|
|
@@ -281,7 +281,7 @@ var mapSquareOne = {
|
|
}
|
|
}
|
|
|
|
|
|
// tractor start position
|
|
// tractor start position
|
|
- this.tractor = game.add.sprite(this.points.x[onePosition], this.points.y[onePosition], 'tractor');
|
|
|
|
|
|
+ this.tractor = game.add.sprite(this.points.x[levelPosition], this.points.y[levelPosition], 'tractor');
|
|
this.tractor.anchor.setTo(0.5, 1);
|
|
this.tractor.anchor.setTo(0.5, 1);
|
|
this.tractor.scale.setTo(0.5);
|
|
this.tractor.scale.setTo(0.5);
|
|
game.physics.arcade.enable(this.tractor);
|
|
game.physics.arcade.enable(this.tractor);
|
|
@@ -296,42 +296,44 @@ var mapSquareOne = {
|
|
},
|
|
},
|
|
|
|
|
|
update: function() {
|
|
update: function() {
|
|
-
|
|
|
|
|
|
+
|
|
// Wait 2 seconds before moving or staring a game
|
|
// Wait 2 seconds before moving or staring a game
|
|
this.count ++;
|
|
this.count ++;
|
|
if(this.count<=this.wait) return;
|
|
if(this.count<=this.wait) return;
|
|
|
|
|
|
// If movement is stopped or position is 6 (final), load game
|
|
// If movement is stopped or position is 6 (final), load game
|
|
- if(onePosition==6){
|
|
|
|
- oneMove = false;
|
|
|
|
|
|
+ if(levelPosition==8){
|
|
|
|
+ levelMove = false;
|
|
}
|
|
}
|
|
- if(!oneMove){
|
|
|
|
|
|
+
|
|
|
|
+ if(!levelMove){
|
|
this.loadGame();
|
|
this.loadGame();
|
|
}
|
|
}
|
|
|
|
|
|
// If momevent is enabled, move to next point from actual
|
|
// If momevent is enabled, move to next point from actual
|
|
- if(oneMove){
|
|
|
|
|
|
+ if(levelMove){
|
|
game.physics.arcade.moveToXY(
|
|
game.physics.arcade.moveToXY(
|
|
this.tractor,
|
|
this.tractor,
|
|
- this.points.x[onePosition+1],
|
|
|
|
- this.points.y[onePosition+1],
|
|
|
|
|
|
+ this.points.x[levelPosition+1],
|
|
|
|
+ this.points.y[levelPosition+1],
|
|
100
|
|
100
|
|
);
|
|
);
|
|
|
|
|
|
// I tractor reached the end, stop movement
|
|
// I tractor reached the end, stop movement
|
|
- if(Math.ceil(this.tractor.x)==this.points.x[onePosition+1] || Math.ceil(this.tractor.y)==this.points.y[onePosition+1]){
|
|
|
|
- oneMove=false;
|
|
|
|
- onePosition += 1; //Update position
|
|
|
|
|
|
+ if(Math.ceil(this.tractor.x)==this.points.x[levelPosition+1] || Math.ceil(this.tractor.y)==this.points.y[levelPosition+1]){
|
|
|
|
+ levelMove=false;
|
|
|
|
+ levelPosition += 1; //Update position
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
},
|
|
},
|
|
|
|
|
|
//MapLoading function
|
|
//MapLoading function
|
|
- loadGame: function(){
|
|
|
|
|
|
+ loadGame: function() {
|
|
if(audioStatus){
|
|
if(audioStatus){
|
|
beepSound.play();
|
|
beepSound.play();
|
|
}
|
|
}
|
|
- if(onePosition<5){
|
|
|
|
|
|
+ if(levelPosition<5){
|
|
game.state.start('gameSOne');
|
|
game.state.start('gameSOne');
|
|
}else{
|
|
}else{
|
|
game.state.start('endSOne');
|
|
game.state.start('endSOne');
|
|
@@ -341,19 +343,6 @@ var mapSquareOne = {
|
|
};
|
|
};
|
|
|
|
|
|
/****************************** GAME ****************************/
|
|
/****************************** GAME ****************************/
|
|
-var startX;
|
|
|
|
-var clicked, hideLabels, animate, checkCollide, result, hasFigure;
|
|
|
|
-var detail;
|
|
|
|
-var endPosition;
|
|
|
|
-var fractionClicked, fractionIndex;
|
|
|
|
-//Balloon and blocks control
|
|
|
|
-var blocks, maxBlocks, numBlocks, curBlock, blockDirection, blockDistance, blockLabel, blockSeparator;
|
|
|
|
-
|
|
|
|
-var blockWidth, blockIndex;
|
|
|
|
-var floorBlocks, floorIndex, floorCount, floorClicked, curFloor;
|
|
|
|
-var move, moveCounter, moveEnd;
|
|
|
|
-var tractor, arrow;
|
|
|
|
-var arrowPlace;
|
|
|
|
|
|
|
|
var gameSquareOne = {
|
|
var gameSquareOne = {
|
|
|
|
|
|
@@ -362,23 +351,18 @@ var gameSquareOne = {
|
|
//timer
|
|
//timer
|
|
totalTime = 0;
|
|
totalTime = 0;
|
|
timer = game.time.create(false);
|
|
timer = game.time.create(false);
|
|
- timer.loop(1000, this.updateCounter, this);
|
|
|
|
|
|
+ timer.loop(1000, this.func_updateCounter, this);
|
|
timer.start();
|
|
timer.start();
|
|
detail="";
|
|
detail="";
|
|
-
|
|
|
|
- // Creating sound variable
|
|
|
|
- beepSound = game.add.audio('sound_beep');
|
|
|
|
- okSound = game.add.audio('sound_ok');
|
|
|
|
- errorSound = game.add.audio('sound_error');
|
|
|
|
|
|
|
|
// Background
|
|
// Background
|
|
game.add.image(0, 0, 'bgimage');
|
|
game.add.image(0, 0, 'bgimage');
|
|
|
|
|
|
- // Menu options
|
|
|
|
- buttonSettings["addButtons"](1,1,
|
|
|
|
|
|
+ // Navigation buttons
|
|
|
|
+ buttonSettings["func_addButtons"](1,1,
|
|
1,1,1,
|
|
1,1,1,
|
|
1,0,
|
|
1,0,
|
|
- "menuSOne", this.viewHelp);
|
|
|
|
|
|
+ "menuSOne", this.func_viewHelp);
|
|
|
|
|
|
//Clouds
|
|
//Clouds
|
|
game.add.image(300, 100, 'cloud');
|
|
game.add.image(300, 100, 'cloud');
|
|
@@ -393,7 +377,7 @@ var gameSquareOne = {
|
|
|
|
|
|
//Floor and road
|
|
//Floor and road
|
|
var startX = 170; //Initial tractor and place position
|
|
var startX = 170; //Initial tractor and place position
|
|
- if(oneOperator=='Minus') startX = 730;
|
|
|
|
|
|
+ if(levelOperator=='Minus') startX = 730;
|
|
startX = startX; //Workaround for initial position inside update
|
|
startX = startX; //Workaround for initial position inside update
|
|
var blockWidth = 80; //Width of blocks and floor spaces
|
|
var blockWidth = 80; //Width of blocks and floor spaces
|
|
var blockHeight = 40; //Height of blocks and floor spaces
|
|
var blockHeight = 40; //Height of blocks and floor spaces
|
|
@@ -413,27 +397,27 @@ var gameSquareOne = {
|
|
|
|
|
|
//tractor
|
|
//tractor
|
|
var tractorAlign = -80;
|
|
var tractorAlign = -80;
|
|
- if(oneOperator=='Minus'){
|
|
|
|
|
|
+ if(levelOperator=='Minus'){
|
|
tractorAlign *= -1;
|
|
tractorAlign *= -1;
|
|
}
|
|
}
|
|
tractor = game.add.sprite(startX+tractorAlign, 445, 'tractor');
|
|
tractor = game.add.sprite(startX+tractorAlign, 445, 'tractor');
|
|
tractor.anchor.setTo(0.5, 0.5);
|
|
tractor.anchor.setTo(0.5, 0.5);
|
|
tractor.scale.setTo(0.8);
|
|
tractor.scale.setTo(0.8);
|
|
tractor.animations.add('right',[0,1,2,3,4]);
|
|
tractor.animations.add('right',[0,1,2,3,4]);
|
|
- if(oneOperator=='Minus'){
|
|
|
|
|
|
+ if(levelOperator=='Minus'){
|
|
tractor.scale.x *= -1;
|
|
tractor.scale.x *= -1;
|
|
}
|
|
}
|
|
|
|
|
|
//generator
|
|
//generator
|
|
//Blocks and fractions
|
|
//Blocks and fractions
|
|
- if(debugmode) console.log("pos " +onePosition);
|
|
|
|
|
|
+ if(debugMode) console.log("pos " +levelPosition);
|
|
|
|
|
|
- maxBlocks = onePosition+4; //Maximum blocks
|
|
|
|
- if(oneType=='B' || oneOperator=='Mixed') maxBlocks = 10;
|
|
|
|
|
|
+ maxBlocks = levelPosition+4; //Maximum blocks
|
|
|
|
+ if(levelType=='B' || levelOperator=='Mixed') maxBlocks = 10;
|
|
blocks = game.add.group(); //Fraction arrays (apilled)
|
|
blocks = game.add.group(); //Fraction arrays (apilled)
|
|
- numBlocks = game.rnd.integerInRange(onePosition+2, maxBlocks); //Number of blocks
|
|
|
|
|
|
+ numBlocks = game.rnd.integerInRange(levelPosition+2, maxBlocks); //Number of blocks
|
|
|
|
|
|
- if(debugmode) console.log("num " + numBlocks+", min " + (onePosition+2) + ", max " + maxBlocks);
|
|
|
|
|
|
+ if(debugMode) console.log("num " + numBlocks+", min " + (levelPosition+2) + ", max " + maxBlocks);
|
|
|
|
|
|
curBlock = 0; //Actual index block
|
|
curBlock = 0; //Actual index block
|
|
blockDirection = []; //Directions right(plus), left (minus)
|
|
blockDirection = []; //Directions right(plus), left (minus)
|
|
@@ -443,7 +427,7 @@ var gameSquareOne = {
|
|
//blockAngle = []; //Angles of blocks
|
|
//blockAngle = []; //Angles of blocks
|
|
//blockTraceColor = []; //Trace colors
|
|
//blockTraceColor = []; //Trace colors
|
|
endPosition = startX; //Ending position, accumulative
|
|
endPosition = startX; //Ending position, accumulative
|
|
- if(oneOperator=='Minus') endPosition -= blockWidth;
|
|
|
|
|
|
+ if(levelOperator=='Minus') endPosition -= blockWidth;
|
|
else endPosition += blockWidth;
|
|
else endPosition += blockWidth;
|
|
|
|
|
|
//Game A exclusive variables
|
|
//Game A exclusive variables
|
|
@@ -455,7 +439,7 @@ var gameSquareOne = {
|
|
|
|
|
|
//Game B exclusive variables
|
|
//Game B exclusive variables
|
|
arrowPlace = startX; //Fixed place for help arrow
|
|
arrowPlace = startX; //Fixed place for help arrow
|
|
- if(oneOperator=='Minus') arrowPlace -= blockWidth;
|
|
|
|
|
|
+ if(levelOperator=='Minus') arrowPlace -= blockWidth;
|
|
else arrowPlace += blockWidth;
|
|
else arrowPlace += blockWidth;
|
|
fractionClicked = false; //If clicked a fraction (game B)
|
|
fractionClicked = false; //If clicked a fraction (game B)
|
|
fractionIndex = -1; //Index of clicked fraction (game B)
|
|
fractionIndex = -1; //Index of clicked fraction (game B)
|
|
@@ -464,18 +448,18 @@ var gameSquareOne = {
|
|
|
|
|
|
for(var p=0;p<numBlocks;p++){
|
|
for(var p=0;p<numBlocks;p++){
|
|
|
|
|
|
- var portion = game.rnd.integerInRange(1, oneDifficulty); //Portion of the square, according to difficulty
|
|
|
|
|
|
+ var portion = game.rnd.integerInRange(1, levelDifficulty); //Portion of the square, according to difficulty
|
|
if(portion==3) detail+= "4,";
|
|
if(portion==3) detail+= "4,";
|
|
else detail += portion+",";
|
|
else detail += portion+",";
|
|
|
|
|
|
- if(portion==oneDifficulty) hasFigure = true;
|
|
|
|
|
|
+ if(portion==levelDifficulty) hasFigure = true;
|
|
var direction = '';
|
|
var direction = '';
|
|
var lineColor = '';
|
|
var lineColor = '';
|
|
|
|
|
|
- if(oneOperator=='Plus'){
|
|
|
|
|
|
+ if(levelOperator=='Plus'){
|
|
direction = 'Right';
|
|
direction = 'Right';
|
|
lineColor = 0x31314e; //plus block: "black'
|
|
lineColor = 0x31314e; //plus block: "black'
|
|
- }else if(oneOperator=='Minus'){
|
|
|
|
|
|
+ }else if(levelOperator=='Minus'){
|
|
direction = 'Left';
|
|
direction = 'Left';
|
|
lineColor = 0xb30000;//minus block : "red"
|
|
lineColor = 0xb30000;//minus block : "red"
|
|
}
|
|
}
|
|
@@ -494,9 +478,9 @@ var gameSquareOne = {
|
|
blockDistance.push(blockWidth);
|
|
blockDistance.push(blockWidth);
|
|
//blockAngle.push(360);
|
|
//blockAngle.push(360);
|
|
|
|
|
|
- if(oneLabel){
|
|
|
|
|
|
+ if(levelLabel){
|
|
var labelX = startX;
|
|
var labelX = startX;
|
|
- if(oneOperator=='Minus') labelX -= (15+blockWidth);
|
|
|
|
|
|
+ if(levelOperator=='Minus') labelX -= (15+blockWidth);
|
|
else labelX += blockWidth+15;
|
|
else labelX += blockWidth+15;
|
|
var label = game.add.text(labelX, 480-p*blockHeight, portion , styleLabel);
|
|
var label = game.add.text(labelX, 480-p*blockHeight, portion , styleLabel);
|
|
label.anchor.setTo(0.5, 0.5);
|
|
label.anchor.setTo(0.5, 0.5);
|
|
@@ -511,9 +495,9 @@ var gameSquareOne = {
|
|
|
|
|
|
blockDistance.push(distance);
|
|
blockDistance.push(distance);
|
|
|
|
|
|
- if(oneLabel){
|
|
|
|
|
|
+ if(levelLabel){
|
|
var labelX = startX;
|
|
var labelX = startX;
|
|
- if(oneOperator=='Minus') labelX -= (15+distance);
|
|
|
|
|
|
+ if(levelOperator=='Minus') labelX -= (15+distance);
|
|
else labelX += 15+distance;
|
|
else labelX += 15+distance;
|
|
var separator = game.add.sprite(labelX, 480-p*blockHeight, 'separator');
|
|
var separator = game.add.sprite(labelX, 480-p*blockHeight, 'separator');
|
|
separator.scale.setTo(0.6);
|
|
separator.scale.setTo(0.6);
|
|
@@ -535,13 +519,13 @@ var gameSquareOne = {
|
|
block.endFill();
|
|
block.endFill();
|
|
|
|
|
|
//If game is type B, (select fractions, adding event)
|
|
//If game is type B, (select fractions, adding event)
|
|
- if(oneType=='B'){
|
|
|
|
|
|
+ if(levelType=='B'){
|
|
block.alpha = 0.5;
|
|
block.alpha = 0.5;
|
|
block.inputEnabled = true;
|
|
block.inputEnabled = true;
|
|
block.input.useHandCursor = true;
|
|
block.input.useHandCursor = true;
|
|
- block.events.onInputDown.add(this.clickSquare, {indice: p});
|
|
|
|
- block.events.onInputOver.add(this.overSquare, {indice: p});
|
|
|
|
- block.events.onInputOut.add(this.outSquare, {indice: p});
|
|
|
|
|
|
+ block.events.onInputDown.add(this.func_clickSquare, {indice: p});
|
|
|
|
+ block.events.onInputOver.add(this.func_overSquare, {indice: p});
|
|
|
|
+ block.events.onInputOut.add(this.func_outSquare, {indice: p});
|
|
}
|
|
}
|
|
|
|
|
|
blocks.add(block);
|
|
blocks.add(block);
|
|
@@ -557,14 +541,14 @@ var gameSquareOne = {
|
|
//If end position is out of bounds, restart
|
|
//If end position is out of bounds, restart
|
|
if(!hasFigure) game.state.start('gameSOne');
|
|
if(!hasFigure) game.state.start('gameSOne');
|
|
|
|
|
|
- if (oneOperator=='Plus' && (endPosition<(startX+blockWidth) || endPosition>(startX+8*blockWidth))){
|
|
|
|
|
|
+ if (levelOperator=='Plus' && (endPosition<(startX+blockWidth) || endPosition>(startX+8*blockWidth))){
|
|
game.state.start('gameSOne');
|
|
game.state.start('gameSOne');
|
|
- }else if (oneOperator=='Minus' && (endPosition>(startX) || endPosition<(startX-(8*blockWidth)))){
|
|
|
|
|
|
+ }else if (levelOperator=='Minus' && (endPosition>(startX) || endPosition<(startX-(8*blockWidth)))){
|
|
game.state.start('gameSOne');
|
|
game.state.start('gameSOne');
|
|
}
|
|
}
|
|
|
|
|
|
//If game is type B, selectiong a random block floor place
|
|
//If game is type B, selectiong a random block floor place
|
|
- if(oneType=='B'){
|
|
|
|
|
|
+ if(levelType=='B'){
|
|
var end = game.rnd.integerInRange(1, numBlocks);
|
|
var end = game.rnd.integerInRange(1, numBlocks);
|
|
for(var i=0;i<end;i++){
|
|
for(var i=0;i<end;i++){
|
|
if(blockDirection[i]=='Right')
|
|
if(blockDirection[i]=='Right')
|
|
@@ -575,11 +559,11 @@ var gameSquareOne = {
|
|
}
|
|
}
|
|
|
|
|
|
//Selectable floor
|
|
//Selectable floor
|
|
- floorCount = 8*oneDifficulty;
|
|
|
|
|
|
+ floorCount = 8*levelDifficulty;
|
|
|
|
|
|
- var widFloor = blockWidth/oneDifficulty;
|
|
|
|
|
|
+ var widFloor = blockWidth/levelDifficulty;
|
|
|
|
|
|
- if(oneDifficulty==3){
|
|
|
|
|
|
+ if(levelDifficulty==3){
|
|
floorCount = 8*4;
|
|
floorCount = 8*4;
|
|
widFloor = blockWidth/4;
|
|
widFloor = blockWidth/4;
|
|
}
|
|
}
|
|
@@ -587,11 +571,11 @@ var gameSquareOne = {
|
|
for(var i = 0; i < floorCount; i++){
|
|
for(var i = 0; i < floorCount; i++){
|
|
var posX = startX;
|
|
var posX = startX;
|
|
|
|
|
|
- if(oneOperator=='Minus') posX -= (blockWidth + i*widFloor);
|
|
|
|
|
|
+ if(levelOperator=='Minus') posX -= (blockWidth + i*widFloor);
|
|
else posX += (blockWidth + i*widFloor);
|
|
else posX += (blockWidth + i*widFloor);
|
|
|
|
|
|
- if(oneType=='B'){
|
|
|
|
- if(oneOperator=='Minus'){
|
|
|
|
|
|
+ if(levelType=='B'){
|
|
|
|
+ if(levelOperator=='Minus'){
|
|
if(posX<=arrowPlace){
|
|
if(posX<=arrowPlace){
|
|
floorCount = i+1;
|
|
floorCount = i+1;
|
|
floorIndex = i-1;
|
|
floorIndex = i-1;
|
|
@@ -613,15 +597,15 @@ var gameSquareOne = {
|
|
block.beginFill(0xa8c0e6);
|
|
block.beginFill(0xa8c0e6);
|
|
block.drawRect(0, 0, widFloor, blockHeight);
|
|
block.drawRect(0, 0, widFloor, blockHeight);
|
|
block.endFill();
|
|
block.endFill();
|
|
- if(oneOperator=='Minus') block.scale.x *= -1;
|
|
|
|
|
|
+ if(levelOperator=='Minus') block.scale.x *= -1;
|
|
|
|
|
|
- if(oneType=="A"){
|
|
|
|
|
|
+ if(levelType=="A"){
|
|
block.alpha = 0.5;
|
|
block.alpha = 0.5;
|
|
block.inputEnabled = true;
|
|
block.inputEnabled = true;
|
|
block.input.useHandCursor = true;
|
|
block.input.useHandCursor = true;
|
|
- block.events.onInputDown.add(this.clickSquare, {indice: i});
|
|
|
|
- block.events.onInputOver.add(this.overSquare, {indice: i});
|
|
|
|
- block.events.onInputOut.add(this.outSquare, {indice: i});
|
|
|
|
|
|
+ block.events.onInputDown.add(this.func_clickSquare, {indice: i});
|
|
|
|
+ block.events.onInputOver.add(this.func_overSquare, {indice: i});
|
|
|
|
+ block.events.onInputOut.add(this.func_outSquare, {indice: i});
|
|
}
|
|
}
|
|
|
|
|
|
floorBlocks.add(block);
|
|
floorBlocks.add(block);
|
|
@@ -629,7 +613,7 @@ var gameSquareOne = {
|
|
|
|
|
|
for(var i=0;i<=8;i++){
|
|
for(var i=0;i<=8;i++){
|
|
var posX = startX;
|
|
var posX = startX;
|
|
- if(oneOperator=='Minus')posX -= ((9-i)*blockWidth);
|
|
|
|
|
|
+ if(levelOperator=='Minus')posX -= ((9-i)*blockWidth);
|
|
else posX+=((i+1)*blockWidth);
|
|
else posX+=((i+1)*blockWidth);
|
|
|
|
|
|
game.add.text(posX, 560, i , stylePlace).anchor.setTo(0.5, 0.5);
|
|
game.add.text(posX, 560, i , stylePlace).anchor.setTo(0.5, 0.5);
|
|
@@ -646,9 +630,9 @@ var gameSquareOne = {
|
|
//Help arrow
|
|
//Help arrow
|
|
arrow = game.add.sprite(this.arrowPlace, 480, 'down');
|
|
arrow = game.add.sprite(this.arrowPlace, 480, 'down');
|
|
arrow.anchor.setTo(0.5, 0.5);
|
|
arrow.anchor.setTo(0.5, 0.5);
|
|
- if(oneType=="B")
|
|
|
|
|
|
+ if(levelType=="B")
|
|
arrow.alpha = 0;
|
|
arrow.alpha = 0;
|
|
- else if(oneType=="A")
|
|
|
|
|
|
+ else if(levelType=="A")
|
|
arrow.alpha = 0.5;
|
|
arrow.alpha = 0.5;
|
|
|
|
|
|
},
|
|
},
|
|
@@ -657,7 +641,7 @@ var gameSquareOne = {
|
|
|
|
|
|
if(!clicked){
|
|
if(!clicked){
|
|
if(!move){
|
|
if(!move){
|
|
- if(oneType=='A'){
|
|
|
|
|
|
+ if(levelType=='A'){
|
|
//Follow mouse
|
|
//Follow mouse
|
|
if (game.physics.arcade.distanceToPointer(arrow, game.input.activePointer) > 8 )
|
|
if (game.physics.arcade.distanceToPointer(arrow, game.input.activePointer) > 8 )
|
|
{
|
|
{
|
|
@@ -746,7 +730,7 @@ var gameSquareOne = {
|
|
}else{
|
|
}else{
|
|
result = false;
|
|
result = false;
|
|
}
|
|
}
|
|
- this.postScore();
|
|
|
|
|
|
+ this.func_postScore();
|
|
move = true;
|
|
move = true;
|
|
checkCollide = false;
|
|
checkCollide = false;
|
|
}
|
|
}
|
|
@@ -760,6 +744,8 @@ var gameSquareOne = {
|
|
if(audioStatus){
|
|
if(audioStatus){
|
|
okSound.play();
|
|
okSound.play();
|
|
}
|
|
}
|
|
|
|
+ passedLevels++;
|
|
|
|
+ if(debugMode) console.log("passedLevels = "+passedLevels);
|
|
okImg.alpha = 1;
|
|
okImg.alpha = 1;
|
|
}else{
|
|
}else{
|
|
if(audioStatus){
|
|
if(audioStatus){
|
|
@@ -772,7 +758,7 @@ var gameSquareOne = {
|
|
moveCounter += 1;
|
|
moveCounter += 1;
|
|
|
|
|
|
if(result){
|
|
if(result){
|
|
- if(oneOperator=='Minus'){
|
|
|
|
|
|
+ if(levelOperator=='Minus'){
|
|
tractor.x -=2;
|
|
tractor.x -=2;
|
|
}else{
|
|
}else{
|
|
tractor.x +=2;
|
|
tractor.x +=2;
|
|
@@ -781,9 +767,9 @@ var gameSquareOne = {
|
|
|
|
|
|
if(moveCounter>=moveEnd){
|
|
if(moveCounter>=moveEnd){
|
|
if(result){
|
|
if(result){
|
|
- oneMove = true;
|
|
|
|
|
|
+ levelMove = true;
|
|
}else{
|
|
}else{
|
|
- oneMove = false;
|
|
|
|
|
|
+ levelMove = false;
|
|
}
|
|
}
|
|
game.state.start('mapSOne');
|
|
game.state.start('mapSOne');
|
|
}
|
|
}
|
|
@@ -791,15 +777,15 @@ var gameSquareOne = {
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- updateCounter: function() {
|
|
|
|
|
|
+ func_updateCounter: function() {
|
|
totalTime++;
|
|
totalTime++;
|
|
},
|
|
},
|
|
|
|
|
|
- overSquare: function(){
|
|
|
|
|
|
+ func_overSquare: function(){
|
|
|
|
|
|
if(!clicked){
|
|
if(!clicked){
|
|
//on level type A
|
|
//on level type A
|
|
- if(oneType=="A"){
|
|
|
|
|
|
+ if(levelType=="A"){
|
|
for(var i=0;i<floorCount;i++){
|
|
for(var i=0;i<floorCount;i++){
|
|
if(i<=this.indice){
|
|
if(i<=this.indice){
|
|
floorBlocks.children[i].alpha = 1;
|
|
floorBlocks.children[i].alpha = 1;
|
|
@@ -809,7 +795,7 @@ var gameSquareOne = {
|
|
}
|
|
}
|
|
floorIndex = this.indice;
|
|
floorIndex = this.indice;
|
|
//on level type B
|
|
//on level type B
|
|
- }else if(oneType=="B"){
|
|
|
|
|
|
+ }else if(levelType=="B"){
|
|
for(var i=0;i<numBlocks;i++){
|
|
for(var i=0;i<numBlocks;i++){
|
|
if(i<=this.indice){
|
|
if(i<=this.indice){
|
|
blocks.children[i].alpha = 0.5;
|
|
blocks.children[i].alpha = 0.5;
|
|
@@ -823,17 +809,17 @@ var gameSquareOne = {
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- outSquare: function(){
|
|
|
|
|
|
+ func_outSquare: function(){
|
|
|
|
|
|
if(!clicked){
|
|
if(!clicked){
|
|
//on level type A
|
|
//on level type A
|
|
- if(oneType=="A"){
|
|
|
|
|
|
+ if(levelType=="A"){
|
|
for(var i=0;i<floorCount;i++){
|
|
for(var i=0;i<floorCount;i++){
|
|
floorBlocks.children[i].alpha = 0.5;
|
|
floorBlocks.children[i].alpha = 0.5;
|
|
}
|
|
}
|
|
floorIndex = -1;
|
|
floorIndex = -1;
|
|
//on level type B
|
|
//on level type B
|
|
- }else if(oneType=="B"){
|
|
|
|
|
|
+ }else if(levelType=="B"){
|
|
for(var i=0;i<numBlocks;i++){
|
|
for(var i=0;i<numBlocks;i++){
|
|
blocks.children[i].alpha = 0.5;
|
|
blocks.children[i].alpha = 0.5;
|
|
}
|
|
}
|
|
@@ -843,12 +829,12 @@ var gameSquareOne = {
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- clickSquare: function(){
|
|
|
|
|
|
+ func_clickSquare: function(){
|
|
|
|
|
|
if(!clicked && !move){
|
|
if(!clicked && !move){
|
|
|
|
|
|
//on level type A
|
|
//on level type A
|
|
- if(oneType=='A'){
|
|
|
|
|
|
+ if(levelType=='A'){
|
|
|
|
|
|
arrow.alpha = 1;
|
|
arrow.alpha = 1;
|
|
clicked = true;
|
|
clicked = true;
|
|
@@ -858,13 +844,13 @@ var gameSquareOne = {
|
|
}
|
|
}
|
|
tractor.animations.play('right', 5, true);
|
|
tractor.animations.play('right', 5, true);
|
|
|
|
|
|
- if(oneLabel){ //Hiding labels
|
|
|
|
|
|
+ if(levelLabel){ //Hiding labels
|
|
blockLabel.visible = false;
|
|
blockLabel.visible = false;
|
|
blockSeparator.visible = false;
|
|
blockSeparator.visible = false;
|
|
}
|
|
}
|
|
|
|
|
|
//cleaning path
|
|
//cleaning path
|
|
- if(oneOperator=='Minus'){
|
|
|
|
|
|
+ if(levelOperator=='Minus'){
|
|
for(var i=0; i< floorCount; i++){
|
|
for(var i=0; i< floorCount; i++){
|
|
if(i>floorIndex){
|
|
if(i>floorIndex){
|
|
floorBlocks.children[i].alpha = 0;
|
|
floorBlocks.children[i].alpha = 0;
|
|
@@ -881,7 +867,7 @@ var gameSquareOne = {
|
|
blockIndex = numBlocks - 1;
|
|
blockIndex = numBlocks - 1;
|
|
|
|
|
|
//on level type B
|
|
//on level type B
|
|
- }else if(oneType=='B'){ //Delete unselected blocks
|
|
|
|
|
|
+ }else if(levelType=='B'){ //Delete unselected blocks
|
|
|
|
|
|
var minusBlocks = 0;
|
|
var minusBlocks = 0;
|
|
for(var i=0;i<numBlocks;i++){
|
|
for(var i=0;i<numBlocks;i++){
|
|
@@ -902,7 +888,7 @@ var gameSquareOne = {
|
|
}
|
|
}
|
|
tractor.animations.play('right', 5, true);
|
|
tractor.animations.play('right', 5, true);
|
|
|
|
|
|
- if(oneLabel){ //Hiding labels
|
|
|
|
|
|
+ if(levelLabel){ //Hiding labels
|
|
blockLabel.visible = false;
|
|
blockLabel.visible = false;
|
|
blockSeparator.visible = false;
|
|
blockSeparator.visible = false;
|
|
}
|
|
}
|
|
@@ -911,72 +897,77 @@ var gameSquareOne = {
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- postScore: function (){
|
|
|
|
-
|
|
|
|
- var lang_str = "pt_BR"; //TODO NAO esta pegando a lingua definida pelo usuario!
|
|
|
|
- var aux;
|
|
|
|
|
|
+ func_postScore: function (){
|
|
|
|
+
|
|
// Get correct information about username and default language
|
|
// Get correct information about username and default language
|
|
- // Variables 'username' and 'lang' is define on: js/menu.js
|
|
|
|
- // Variable 'lang' has all the JSON content of 'assets/languages/pt_BR.json', 'lang.lang' defined in 'js/preMenu.js' (setLang())
|
|
|
|
- // TODO: nao descobri esquema para pegar 'lang' (como 'pt_BR' ou 'en_US'), 'lang' esta' com o dicinario de lingua (definido em 'assets/languages/pt_BR.json').
|
|
|
|
- if (name=='') name = username; //leo the correct is 'username'
|
|
|
|
|
|
+ // Variables 'username' and 'lang' is define on: js/menu.js
|
|
|
|
+ // Variable 'lang' has all the JSON content of 'assets/languages/pt_BR.json', 'lang.lang' defined in 'js/preMenu.js' (func_setLang())
|
|
|
|
+ // TODO: nao descobri esquema para pegar 'lang' (como 'pt_BR' ou 'en_US'), 'lang' esta' com o dicinario de lingua (definido em 'assets/languages/pt_BR.json').
|
|
|
|
+
|
|
|
|
+ //if (name=='') name = username; //leo the correct is 'username'
|
|
|
|
+
|
|
// assets/languages/pt_BR.json
|
|
// assets/languages/pt_BR.json
|
|
|
|
|
|
//DEBUG Testar 'lang'
|
|
//DEBUG Testar 'lang'
|
|
- /*
|
|
|
|
|
|
+ /*
|
|
|
|
+
|
|
var contact = "";
|
|
var contact = "";
|
|
if (typeof lang === 'object') {
|
|
if (typeof lang === 'object') {
|
|
//contact = JSON.parse(lang);
|
|
//contact = JSON.parse(lang);
|
|
for (var i in lang) // will enumerate values of 'assets/languages/pt_BR.json'
|
|
for (var i in lang) // will enumerate values of 'assets/languages/pt_BR.json'
|
|
contact += lang[i];
|
|
contact += lang[i];
|
|
- // Finaliza com os valores de 'assets/languages/pt_BR.json': 'CARREGANDOFraçõesSELECIONE UM JOGODificuldadeNívelSELECINAR OPERAÇÃO E DIFICULDADEBom trabalho!Tente novamente!SELECIONAR IDIOMAMENU PRINCIPALVOLTARVER
|
|
|
|
- // SOLUÇÃOCírculosQuadriláteroslegendaMODOCOMSEMDIGITE SEU NOMEPRONTOOláVocê deve selecionar uma porção menor que o seu tamanho totalVocê esqueceu de digitar seu nomeÁUDIO'
|
|
|
|
|
|
+ // Finaliza com os valores de 'assets/languages/pt_BR.json': 'CARREGANDOFraçõesSELECIONE UM JOGODificuldadeNÃvelSELECINAR OPERAÇÃO E DIFICULDADEBom trabalho!Tente novamente!SELECIONAR IDIOMAMENU PRINCIPALVOLTARVER
|
|
|
|
+ // SOLUÇÃOCÃrculosQuadriláteroslegendaMODOCOMSEMDIGITE SEU NOMEPRONTOOláVocê deve selecionar uma porção menor que o seu tamanho totalVocê esqueceu de digitar seu nomeÃ�UDIO'
|
|
lang_str = contact; aux = 1;
|
|
lang_str = contact; aux = 1;
|
|
- }
|
|
|
|
- else
|
|
|
|
- // if (lang === 'undefined') lang_str = "pt_BR";
|
|
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ // if (lang === 'undefined') lang_str = "pt_BR";
|
|
|
|
+
|
|
*/
|
|
*/
|
|
|
|
|
|
- var abst = "numBlocks:"+numBlocks+", valBlocks: " + detail+" blockIndex: " + blockIndex + ", floorIndex: " + floorIndex;
|
|
|
|
|
|
+ var abst = "numBlocks:" + numBlocks + ", valBlocks: " + detail + " blockIndex: " + blockIndex + ", floorIndex: " + floorIndex;
|
|
|
|
|
|
var hr = new XMLHttpRequest();
|
|
var hr = new XMLHttpRequest();
|
|
|
|
+
|
|
// Create some variables we need to send to our PHP file
|
|
// Create some variables we need to send to our PHP file
|
|
var url = "assets/cn/save.php";
|
|
var url = "assets/cn/save.php";
|
|
- var vars = "s_ip="+hip+"&s_name=" + name+"&s_lang=" + lang_str + "&s_game=" + oneShape + "&s_mode=" + oneType;
|
|
|
|
- vars += "&s_oper=" + oneOperator + "&s_leve=" + oneDifficulty + "&s_posi=" + onePosition + "&s_resu=" + result + "&s_time=" + totalTime + "&s_deta=" + abst;
|
|
|
|
|
|
+ var vars = "s_ip=" + hip + "&s_name=" + username + "&s_lang=" + lang + "&s_game=" + levelShape + "&s_mode=" + levelType;
|
|
|
|
+
|
|
|
|
+ vars += "&s_oper=" + levelOperator + "&s_leve=" + levelDifficulty + "&s_posi=" + levelPosition + "&s_resu=" + result + "&s_time=" + totalTime + "&s_deta=" + abst;
|
|
|
|
|
|
//D alert('/js/squareOne.js: url=' + url + '; aux=' + aux + ', lang_str=' + lang_str + ', lang=' + lang); // + ', this.lang=" + this.lang
|
|
//D alert('/js/squareOne.js: url=' + url + '; aux=' + aux + ', lang_str=' + lang_str + ', lang=' + lang); // + ', this.lang=" + this.lang
|
|
- //D /js/squareOne.js: url=assets/cn/save.php; aux=1, lang_str=CARREGANDOFraçõesSELECIONE UM JOGODificuldadeNívelSELECINAR OPERAÇÃO E DIFICULDADEBom trabalho!Tente novamente!SELECIONAR IDIOMAMENU PRINCIPALVOLTARVER
|
|
|
|
- //D SOLUÇÃOCírculosQuadriláteroslegendaMODOCOMSEMDIGITE SEU NOMEPRONTOOláVocê deve selecionar uma porção menor que o seu tamanho totalVocê esqueceu de digitar seu nomeÁUDIO, lang=[object Object]
|
|
|
|
|
|
+ //D /js/squareOne.js: url=assets/cn/save.php; aux=1, lang_str=CARREGANDOFraçõesSELECIONE UM JOGODificuldadeNÃvelSELECINAR OPERAÇÃO E DIFICULDADEBom trabalho!Tente novamente!SELECIONAR IDIOMAMENU PRINCIPALVOLTARVER
|
|
|
|
+ //D SOLUÇÃOCÃrculosQuadriláteroslegendaMODOCOMSEMDIGITE SEU NOMEPRONTOOláVocê deve selecionar uma porção menor que o seu tamanho totalVocê esqueceu de digitar seu nomeÃ�UDIO, lang=[object Object]
|
|
|
|
|
|
// Sobre nome do usuario:
|
|
// Sobre nome do usuario:
|
|
- // * js/squareOne.js: name
|
|
|
|
- // * js/pt_BR.json: welcome="Ola'", insert_name="DIGITE SEU NOME"
|
|
|
|
- // * assets/cn/save.php : $play = $_REQUEST["s_name"];
|
|
|
|
- // * js/preMenu.js : insert_name, game.add.text(...), username = document.getElementById("name_id").value;
|
|
|
|
|
|
+ // * js/squareOne.js: name
|
|
|
|
+ // * js/pt_BR.json: welcome="Ola'", insert_name="DIGITE SEU NOME"
|
|
|
|
+ // * assets/cn/save.php : $play = $_REQUEST["s_name"];
|
|
|
|
+ // * js/preMenu.js : insert_name, game.add.text(...), username = document.getElementById("name_id").value;
|
|
|
|
|
|
- // Pegar valor de PHP para JS: echo("<script language='javascript'>location.href='download.php?arquivo=$nome_arquivo&dir=$dir&id_exer=$id_exer'</script>");
|
|
|
|
|
|
+ // Pegar valor de PHP para JS: echo("<script language='javascript'>location.href='download.php?arquivo=$nome_arquivo&dir=$dir&id_exer=$id_exer'</script>");
|
|
|
|
|
|
hr.open("POST", url, true);
|
|
hr.open("POST", url, true);
|
|
hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
|
hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
|
hr.onreadystatechange = function() {
|
|
hr.onreadystatechange = function() {
|
|
- if(debugmode) console.log(hr);
|
|
|
|
|
|
+ if(debugMode) console.log(hr);
|
|
|
|
+
|
|
if(hr.readyState == 4 && hr.status == 200) {
|
|
if(hr.readyState == 4 && hr.status == 200) {
|
|
var return_data = hr.responseText;
|
|
var return_data = hr.responseText;
|
|
- if(debugmode) console.log(return_data);
|
|
|
|
|
|
+ if(debugMode) console.log(return_data);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// Send the data to PHP now... and wait for response to update the status div
|
|
// Send the data to PHP now... and wait for response to update the status div
|
|
hr.send(vars); // Actually execute the request
|
|
hr.send(vars); // Actually execute the request
|
|
- if(debugmode) console.log("processing...");
|
|
|
|
|
|
+ if(debugMode) console.log("processing...");
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- viewHelp: function(){
|
|
|
|
|
|
+ func_viewHelp: function(){
|
|
|
|
|
|
if(!clicked){
|
|
if(!clicked){
|
|
var pointer;
|
|
var pointer;
|
|
- if(oneType=='A'){
|
|
|
|
|
|
+ if(levelType=='A'){
|
|
var pointer = game.add.image(endPosition, 490, 'pointer');
|
|
var pointer = game.add.image(endPosition, 490, 'pointer');
|
|
}else{
|
|
}else{
|
|
var pointer = game.add.image(blocks.children[endIndex-1].x, blocks.children[endIndex-1].y-blockSize/2, 'pointer');
|
|
var pointer = game.add.image(blocks.children[endIndex-1].x, blocks.children[endIndex-1].y-blockSize/2, 'pointer');
|
|
@@ -994,11 +985,6 @@ var gameSquareOne = {
|
|
var endSquareOne = {
|
|
var endSquareOne = {
|
|
|
|
|
|
create: function() {
|
|
create: function() {
|
|
-
|
|
|
|
- // Creating sound variable
|
|
|
|
- this.beepSound = game.add.audio('sound_beep');
|
|
|
|
- this.okSound = game.add.audio('sound_ok');
|
|
|
|
- this.errorSound = game.add.audio('sound_error');
|
|
|
|
|
|
|
|
// Background
|
|
// Background
|
|
game.add.image(0, 0, 'bgimage');
|
|
game.add.image(0, 0, 'bgimage');
|
|
@@ -1019,12 +1005,12 @@ var endSquareOne = {
|
|
}
|
|
}
|
|
|
|
|
|
// Progress bar
|
|
// Progress bar
|
|
- for(var p=1;p<=5;p++){
|
|
|
|
- var block = game.add.image(660+(p-1)*30, 10, 'block');
|
|
|
|
|
|
+ for(var p=0;p<5;p++){
|
|
|
|
+ var block = game.add.image(660+p*30, 10, 'block');
|
|
block.scale.setTo(2, 1); //Scaling to double width
|
|
block.scale.setTo(2, 1); //Scaling to double width
|
|
}
|
|
}
|
|
game.add.text(820, 10, '100%', styleMenu);
|
|
game.add.text(820, 10, '100%', styleMenu);
|
|
- game.add.text(650, 10, lang.difficulty + ' ' + oneDifficulty, styleMenu).anchor.setTo(1,0);
|
|
|
|
|
|
+ game.add.text(650, 10, lang.difficulty + ' ' + levelDifficulty, styleMenu).anchor.setTo(1,0);
|
|
game.add.image(660, 10, 'pgbar');
|
|
game.add.image(660, 10, 'pgbar');
|
|
|
|
|
|
//Farm and trees
|
|
//Farm and trees
|
|
@@ -1047,7 +1033,8 @@ var endSquareOne = {
|
|
if(this.tractor.x<=700){
|
|
if(this.tractor.x<=700){
|
|
this.tractor.x += 2;
|
|
this.tractor.x += 2;
|
|
}else{
|
|
}else{
|
|
- if(oneMenu){
|
|
|
|
|
|
+ if(levelMenu){
|
|
|
|
+ passedLevels = 0;
|
|
game.state.start('menu');
|
|
game.state.start('menu');
|
|
}else{
|
|
}else{
|
|
this.tractor.animations.stop();
|
|
this.tractor.animations.stop();
|
|
@@ -1056,15 +1043,8 @@ var endSquareOne = {
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
- verPrincipal: function(){
|
|
|
|
|
|
+ func_verPrincipal: function(){
|
|
game.state.start('welcome');
|
|
game.state.start('welcome');
|
|
},
|
|
},
|
|
-
|
|
|
|
- verMenu: function(){
|
|
|
|
- if(oneMenu){
|
|
|
|
- game.state.start('menu');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
|
|
};
|
|
};
|