Browse Source

phaser files changed from ./js to ./js/phaser | deleted jquery.min.js because it wasn't being used | updating variable declaration from var to let/const due to scope problems | code refactoring

lairaalmas 4 years ago
parent
commit
795e0e6a7e
12 changed files with 443 additions and 461 deletions
  1. 12 12
      index.html
  2. 83 97
      js/boot.js
  3. 96 96
      js/circleOne.js
  4. 0 4
      js/jquery.min.js
  5. 28 28
      js/map.js
  6. 12 12
      js/menu.js
  7. 0 0
      js/phaser/phaser.js
  8. 1 0
      js/phaser/phaser.map
  9. 0 0
      js/phaser/phaser.min.js
  10. 25 26
      js/preMenu.js
  11. 99 99
      js/squareOne.js
  12. 87 87
      js/squareTwo.js

+ 12 - 12
index.html

@@ -9,7 +9,7 @@
         <title> iFractions </title>
         <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
         
-        <script src="js/phaser.min.js"></script>
+        <script src="js/phaser/phaser.min.js"></script>
         
         <script type="text/javascript" src="js/preMenu.js"></script>
         <script type="text/javascript" src="js/menu.js"></script>
@@ -37,7 +37,7 @@
 			  color: rgb(0, 0, 0);
 			  text-align: center;
 			}
-			
+
         </style>
 
     </head>
@@ -62,36 +62,36 @@
 	        <div class="panel panel-info">
 	          <div class="panel-heading">TEAM</div>
 	          <div class="panel-body">
-	            <center>
+				<center>
 	                <ul>
 	                  <li><strong>BRAZIL:</strong> Le&ocirc;nidas de Oliveira Brand&atilde;o (IME-USP)</li>
 	                  <li><strong>PERU:</strong> Manuel Ibarra and Cristhian Serrano (EAPIIS-UNAMBA)</li>
 	                  <li><strong>FRANCE:</strong> Jean-Marc (MOCAH-UPMC)</li>
-	                </ul>
-	            </center>
+					</ul>
+				</center>
 	          </div>
 	        </div>
 	        
 	        <div class="panel panel-default">
 	          <div class="panel-heading">BASED ON</div>
 	          <div class="panel-body">
-	            <center>
+				  <center>
 	                <ul>
 	                  <li><strong>iLM </strong>(interactive Learning Modules) </li>
 	                  <li><strong>Six facets of Serious Game Design</strong>: Pedagogical Objectives; Domain Simulation; Interactions with the Simulation;<br>Problems and Progression; Decorum and Conditions of Use.</li>
-	                </ul>
-	            </center>
-	          </div>
+					</ul>
+				  </center>
+				</div>
 	        </div>
 	        
 	        <div class="panel panel-danger">
 	          <div class="panel-heading">TECHNOLOGY</div>
 	          <div class="panel-body">
-	            <center>
+				  <center>
 	                <ul>
 	                  <li> We used <strong>HTML5</strong>, <strong>CSS</strong> and the <strong>Javascript</strong> library <a href="http://phaser.io/" target="_blank"><strong>Phaser.io</strong></a> </li>
-	                </ul>
-	            </center>
+					</ul>
+				  </center>
 	          </div>
 	        </div>
 

+ 83 - 97
js/boot.js

@@ -1,92 +1,99 @@
+
+/*
+    let loadAssets = {
+		preload: function(){},
+		create: function()
+        ---------------------------- end of phaser functions
+	};
+*/
+
 // OUTRAS VARIAVEIS GLOBAIS
 
-				var passedLevels;
+				let passedLevels;
 
 				//premenu
-				var errorEmptyName;
+				let errorEmptyName;
 
 				//map
-				var kid, tractor;
+				let kid, tractor;
 
 				//square 1 + circle 1
-				var startX;
-				var clicked, hideLabels, animate, checkCollide, result, hasFigure;
-				var detail;
-				var endPosition;
-				var fractionClicked, fractionIndex;
-				var blocks, maxBlocks, numBlocks, curBlock, blockDirection, blockDistance, blockLabel, blockSeparator; //blocks control
+				let startX;
+				let clicked, hideLabels, checkCollide, result, hasFigure;
+				let detail;
+				let endPosition;
+				let fractionClicked, fractionIndex;
+				let blocks, maxBlocks, numBlocks, curBlock, blockDirection, blockDistance, blockLabel, blockSeparator; //blocks control
 
 				//square 1
-				var blockWidth, blockIndex;
-				var floorBlocks, floorIndex, floorCount, floorClicked, curFloor;
-				var move, moveCounter, moveEnd;
-				var arrow;
-				var arrowPlace;
+				let blockWidth, blockIndex;
+				let floorBlocks, floorIndex, floorCount, floorClicked, curFloor;
+				let move, moveCounter, moveEnd;
+				let arrow;
+				let arrowPlace;
 
 				//circle 1
-				var blockSize, blockAngle, blockTraceColor;
-				var fly, flyCounter, flyend; //flyvariables
-				var trace; //circle trace
-				var numPlus, endIndex;
-				var kid_walk, balloon, basket;
-				var balloonPlace;
+				let blockSize, blockAngle, blockTraceColor;
+				let fly, flyCounter, flyend; //flyvariables
+				let trace; //circle trace
+				let numPlus, endIndex;
+				let kid_walk, balloon, basket;
+				let balloonPlace;
 
 				//square 2
-				var sizeA, sizeB, valueA, valueB;
-				var clickA, clickB, animateA, animateB, result, animate, cDelay, eDelay;
-				var blocksA, blocksB, auxblqA, auxblqB;
-				var labelA, fractionA, separatorA, labelB, fractionB, separatorB;
-				var kidDirection, equals, counter, endCounter;
-				var xA, yA, xB, yB, blockW, blockH;
+				let sizeA, sizeB, valueA, valueB;
+				let clickA, clickB, animateA, animateB, animate, cDelay, eDelay;
+				let blocksA, blocksB, auxblqA, auxblqB;
+				let labelA, fractionA, separatorA, labelB, fractionB, separatorB;
+				let kidDirection, equals, counter, endCounter;
+				let xA, yA, xB, yB, blockW, blockH;
 
 	// INFO
-	var username; //player name
-	var lang; //language
+	let username; //player name
+	let lang; //language
 
 	// IMAGES
-	var beepSound, okSound, errorSound; //sounds
-	var okImg, errorImg;
-    var timer, totalTime;
+	let beepSound, okSound, errorSound; //sounds
+	let okImg, errorImg;
+    let timer, totalTime;
 
     // variaveis globais
-    var audioStatus = false; // turns game audio on/off
-    var firstTime = true; //if player has just oppened the game
-    var debugMode = false; //turns console messages for developers on/off (changeable only by code)
-
-    // game dimentions
-    var defaultWidth = 900;
-    var defaultHeight = 600;
-
-    // Initialize the game
-    var game = new Phaser.Game(
-        defaultWidth, 
-        defaultHeight, 
-        Phaser.CANVAS,
-        'fractions-game'
-    );
-
-    hip = "143.107.45.11"; //Host ip
-    name = ""; //player name
-    lang = ""; //language
-
+    let audioStatus = false; // turns game audio on/off
+    let firstTime = true; //if player has just oppened the game
+    let debugMode = true; //turns console messages for developers on/off (changeable only by code)
+
+	// game dimentions
+	const defaultWidth = 900;
+	const defaultHeight = 600;
+
+	// Initialize the game
+	let game = new Phaser.Game(
+		defaultWidth, 
+		defaultHeight, 
+		Phaser.CANVAS,
+		'fractions-game'
+	);
+	
+    const hip = "143.107.45.11"; //Host ip
+	
     // Game One : kid and truck
 
-    levelPosition = 0; //Map position
-    levelMove = false; //Move to next position
-    levelDifficulty = 0; //From one to five 
+    let levelPosition = 0; //Map position
+    let levelMove = false; //Move to next position
+    let levelDifficulty = 0; //From one to five 
 
-    levelOperator= ""; //Plus; Minus; Mixed 
+    let levelOperator = ""; //Plus; Minus; Mixed 
 
-    levelLabel= false; //Show block label
-    levelShape = ""; //Circle; square
-    levelType = ""; // A - Place distance; B - Select blocks
-    levelMenu = true;
+    let levelLabel= false; //Show block label
+    let levelShape = ""; //Circle; square
+    let levelType = ""; // A - Place distance; B - Select blocks
+    let levelMenu = true;
 
     //adding game states (scenes)
     
-    game.state.add('language', langState); // boot.js
-    game.state.add('load', loadState); // boot.js
-    game.state.add('name', nameState); // boot.js
+    game.state.add('language', langState); // preMenu.js
+    game.state.add('load', loadState); // preMenu.js
+    game.state.add('name', nameState); // preMenu.js
 
     game.state.add('menu', menuState); // menu.js
 
@@ -104,16 +111,12 @@
     game.state.add('gameSquareTwo', gameSquareTwo); // squareTwo.js
     game.state.add('endSquareTwo', endSquareTwo); // squareTwo.js
 
-    var loadAssets = {
-    		
-    	levelSpriteList: null,
-    	levelShapeList: null,
-    	levelTypeList: null,
+    let loadAssets = {
 
     	preload: function(){
 
     		//auxiliar directory
-	        var imgsrc = 'assets/img/';
+	        const imgsrc = 'assets/img/';
 
 	        //Progress bar image
 	        game.load.image('progressBar', imgsrc+'pgbar.png');
@@ -136,7 +139,7 @@
 	        this.levelSpriteList = [];
 
 	        
-	        var levelSpriteSource = [
+	        let levelSpriteSource = [
 	        	'1-left-subs.png', 	//square I
 	        	'2-left-subs.png', 	//square II
 	        	'3-left-subs.png',	//circle I
@@ -146,13 +149,7 @@
 			
 			
 	        if(debugMode){
-	        	levelSpriteSource = [
-		        	'1-left-subs.png', 	//square I
-		        	'2-left-subs.png', 	//square II
-		        	'3-left-subs.png',	//circle I
-		        	'4-left-subs.png',	//circle II
-		        	'5.png',			//square III
-
+	        	levelSpriteSource.push(
 		        	'5.png',
 		        	'5.png',
 		        	'5.png',
@@ -162,11 +159,11 @@
 		        	'5.png',
 		        	'5.png',
 		        	'5.png'
-	        	];
+				);
 	    	}
 			
 
-	        for(var i=0; i<levelSpriteSource.length; i++){
+	        for(let i=0; i<levelSpriteSource.length; i++){
 	        	this.levelSpriteList[i] = 'game'+i;
 	        	game.load.image(this.levelSpriteList[i], 	imgsrc+'game/'+levelSpriteSource[i]);
 	        }
@@ -182,13 +179,7 @@
 			
 			
 			if(debugMode){
-				this.levelShapeList = [
-					'Square', 
-					'Square', 
-					'Circle', 
-					'Circle', 
-					'Square',
-
+				this.levelShapeList.push(
 					'Square', 
 					'Square', 
 					'Square', 
@@ -198,7 +189,7 @@
 					'Square', 
 					'Square', 
 					'Square'
-				];
+				);
 			}
 			
         	this.levelTypeList  = [
@@ -211,13 +202,7 @@
         	
 	       	
 	       	if(debugMode){
-	       		this.levelTypeList  = [
-	        		1, 
-	        		2, 
-	        		1, 
-	        		2, 
-	        		3,
-
+	       		this.levelTypeList.push(
 	        		3, 
 	        		3, 
 	        		3, 
@@ -227,7 +212,7 @@
 	        		3, 
 	        		3, 
 	        		3
-	        	];
+				);
 	        }
 	       	
 
@@ -298,6 +283,7 @@
     	
     };
 
-    //starting to boot game
-    game.state.add('loadAssets', loadAssets); // squareTwo.js
-   	game.state.start('loadAssets');
+    game.state.add('loadAssets', loadAssets); // boot.js
+
+	// We finished loading everything and the first state is called
+	game.state.start('loadAssets');

+ 96 - 96
js/circleOne.js

@@ -1,12 +1,12 @@
 
 /*
-    var menuCircleOne = {
+    let menuCircleOne = {
         create: function(){},
         ---------------------------- end of phaser functions
         func_loadMap: function(){}
     };
 
-    var gameCircleOne = {
+    let gameCircleOne = {
         create: function(){},
         update: function(){},
         ---------------------------- end of phaser functions
@@ -21,7 +21,7 @@
             //func_getRndDivisor: function(){}
     };
 
-    var endCircleOne = {
+    let endCircleOne = {
         create: function(){},
         update: function(){},
         ---------------------------- end of phaser functions
@@ -33,7 +33,7 @@
 
 /****************************** MENU ****************************/
 
-var menuCircleOne = {
+let menuCircleOne = {
     
     create: function() {
                 
@@ -44,46 +44,46 @@ var menuCircleOne = {
                                     false,false);        
         
         // Title
-        var style = { font: '28px Arial', fill: '#00804d'};
-        var title = game.add.text(game.world.centerX, 40, lang.game_menu_title, style);
+        const style = { font: '28px Arial', fill: '#00804d'};
+        let title = game.add.text(game.world.centerX, 40, lang.game_menu_title, style);
         title.anchor.setTo(0.5, 0.5);
                 
         //SETTING DIFFICULTY LEVELS
 
-        var maxHeight = 120; //Max height of a stair
-        var stairHeight = 29; //height growth of a stair
-        var stairWidth = 85; //Width of a stair
-        var startStair = 240;
-        var startSymbol = 150;
-        var startCircle = (startSymbol/2)+startStair+stairWidth*5;
+        let maxHeight = 120; //Max height of a stair
+        let stairHeight = 29; //height growth of a stair
+        let stairWidth = 85; //Width of a stair
+        let startStair = 240;
+        let startSymbol = 150;
+        let startCircle = (startSymbol/2)+startStair+stairWidth*5;
         
          //First stairs, plus, 5 levels, blue circle
 
-        var blueCircle = game.add.graphics(startCircle, 195);
+        let blueCircle = game.add.graphics(startCircle, 195);
             blueCircle.anchor.setTo(0.5,0.5);
             blueCircle.lineStyle(2, 0x31314e);
             blueCircle.beginFill(0xefeff5);
             blueCircle.drawCircle(0, 0, 60);
             blueCircle.endFill();
 
-        var plusArrowIcon = game.add.sprite(startSymbol+40, 195, 'h_arrow'); 
+        let plusArrowIcon = game.add.sprite(startSymbol+40, 195, 'h_arrow'); 
             plusArrowIcon.scale.setTo(0.35);
             plusArrowIcon.alpha = 0.8;
             plusArrowIcon.anchor.setTo(0.5,0.5);
 
-        var plusKidIcon = game.add.sprite(startSymbol, 195, 'kid_walk'); 
+        let plusKidIcon = game.add.sprite(startSymbol, 195, 'kid_walk'); 
             plusKidIcon.scale.setTo(0.6);
             plusKidIcon.alpha = 0.8;
             plusKidIcon.anchor.setTo(0.5,0.5);
         
-        var stairsPlus = [];
+        let stairsPlus = [];
 
-        for(var i=1;i<=5;i++){
+        for(let i=1;i<=5;i++){
             //stair
-            var x1 = startStair+(stairWidth*(i-1));
-            var y1 = 135+maxHeight-i*stairHeight;
-            var x2 = stairWidth;//x1 + 40;
-            var y2 = stairHeight*i;//y1 + 24;
+            let x1 = startStair+(stairWidth*(i-1));
+            let y1 = 135+maxHeight-i*stairHeight;
+            let x2 = stairWidth;//x1 + 40;
+            let y2 = stairHeight*i;//y1 + 24;
             
             stairsPlus[i] = game.add.graphics(0, 0);
             stairsPlus[i].lineStyle(1, 0xFFFFFF, 1);
@@ -99,39 +99,39 @@ var menuCircleOne = {
             stairsPlus[i].events.onInputOut.add(function (item) { item.alpha=1; }, this);
             
             //label
-            var xl = x1+stairWidth/2; //x label
-            var yl = y1+(stairHeight*i)/2; //y label
-            var label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' });
+            let xl = x1+stairWidth/2; //x label
+            let yl = y1+(stairHeight*i)/2; //y label
+            let label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' });
                 label.anchor.setTo(0.5, 0.4);
         }
         
         //Second stairs, minus, 5 levels, red circle
 
-        var redCircle = game.add.graphics(startCircle, 350);
+        let redCircle = game.add.graphics(startCircle, 350);
             redCircle.anchor.setTo(0.5,0.5);
             redCircle.lineStyle(2, 0xb30000);
             redCircle.beginFill(0xefeff5);
             redCircle.drawCircle(0, 0, 60);
             redCircle.endFill();
 
-        var minusArrowIcon = game.add.sprite(startSymbol, 350, 'h_arrow');
+        let minusArrowIcon = game.add.sprite(startSymbol, 350, 'h_arrow');
             minusArrowIcon.scale.setTo(-0.35, 0.35);
             minusArrowIcon.alpha = 0.8;
             minusArrowIcon.anchor.setTo(0.5,0.5);
 
-        var minusKidIcon = game.add.sprite(startSymbol+40, 350, 'kid_walk');
+        let minusKidIcon = game.add.sprite(startSymbol+40, 350, 'kid_walk');
             minusKidIcon.scale.setTo(-0.6, 0.6);
             minusKidIcon.alpha = 0.8;
             minusKidIcon.anchor.setTo(0.5,0.5);
 
-        var stairsMinus = [];
+        let stairsMinus = [];
 
-        for(var i=1;i<=5;i++){
+        for(let i=1;i<=5;i++){
             //stair
-            var x1 = startStair+(stairWidth*(i-1));
-            var y1 = 285+maxHeight-i*stairHeight;
-            var x2 = stairWidth;//x1 + 40;
-            var y2 = stairHeight*i;//y1 + 24;
+            let x1 = startStair+(stairWidth*(i-1));
+            let y1 = 285+maxHeight-i*stairHeight;
+            let x2 = stairWidth;//x1 + 40;
+            let y2 = stairHeight*i;//y1 + 24;
             
             stairsMinus[i] = game.add.graphics(0, 0);
             stairsMinus[i].lineStyle(1, 0xFFFFFF, 1);
@@ -146,41 +146,41 @@ var menuCircleOne = {
             stairsMinus[i].events.onInputOver.add(function (item) { item.alpha=0.5; }, this);
             stairsMinus[i].events.onInputOut.add(function (item) { item.alpha=1; }, this);
             //label
-            var xl = x1+stairWidth/2; //x label
-            var yl = y1+(stairHeight*i)/2; //y label
-            var label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' });
+            let xl = x1+stairWidth/2; //x label
+            let yl = y1+(stairHeight*i)/2; //y label
+            let label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' });
                 label.anchor.setTo(0.5, 0.4);
         } 
         
         //Thrid stairs, mixed, 5 levels, two circles
 
-        var blueCircle2 = game.add.graphics(startCircle-30, 500);
+        let blueCircle2 = game.add.graphics(startCircle-30, 500);
             blueCircle2.anchor.setTo(0.5,0.5);
             blueCircle2.lineStyle(2, 0x31314e);
             blueCircle2.beginFill(0xefeff5);
             blueCircle2.drawCircle(0, 0, 60);
             blueCircle2.endFill();
         
-        var redCircle2 = game.add.graphics(startCircle+40, 500);
+        let redCircle2 = game.add.graphics(startCircle+40, 500);
             redCircle2.anchor.setTo(0.5,0.5);
             redCircle2.lineStyle(2, 0xb30000);
             redCircle2.beginFill(0xefeff5);
             redCircle2.drawCircle(0, 0, 60);
             redCircle2.endFill();
         
-        var doubleArrowIcon = game.add.sprite(startSymbol, 500, 'h_double'); 
+        let doubleArrowIcon = game.add.sprite(startSymbol, 500, 'h_double'); 
             doubleArrowIcon.scale.setTo(0.5);
             doubleArrowIcon.anchor.setTo(0.5,0.5);
             doubleArrowIcon.alpha = 0.8;
         
-        var stairsMixed = [];
+        let stairsMixed = [];
 
-        for(var i=1;i<=5;i++){
+        for(let i=1;i<=5;i++){
             //stair
-            var x1 = startStair+(stairWidth*(i-1));
-            var y1 = 435+maxHeight-i*stairHeight;
-            var x2 = stairWidth;//x1 + 40;
-            var y2 = stairHeight*i;//y1 + 24;
+            let x1 = startStair+(stairWidth*(i-1));
+            let y1 = 435+maxHeight-i*stairHeight;
+            let x2 = stairWidth;//x1 + 40;
+            let y2 = stairHeight*i;//y1 + 24;
             
             stairsMixed[i] = game.add.graphics(0, 0);
             stairsMixed[i].lineStyle(1, 0xFFFFFF, 1);
@@ -196,9 +196,9 @@ var menuCircleOne = {
             stairsMixed[i].events.onInputOut.add(function (item) { item.alpha=1; }, this);
             
             //label
-            var xl = x1+stairWidth/2; //x label
-            var yl = y1+(stairHeight*i)/2; //y label
-            var label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' });
+            let xl = x1+stairWidth/2; //x label
+            let yl = y1+(stairHeight*i)/2; //y label
+            let label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' });
                 label.anchor.setTo(0.5, 0.4);
         } 
 
@@ -225,7 +225,7 @@ var menuCircleOne = {
 
 /****************************** GAME ****************************/
 
-var gameCircleOne = {
+let gameCircleOne = {
 
     create: function() {
         
@@ -251,9 +251,9 @@ var gameCircleOne = {
         game.add.image(110, 85, 'cloud').scale.setTo(0.8);
         
         // Styles for labels
-        var stylePlace = { font: '26px Arial', fill: '#400080', align: 'center'};
-        var styleLabel = { font: '26px Arial', fill: '#000080', align: 'center'};
-        var styleMenu = { font: '30px Arial', fill: '#000000', align: 'center'};
+        let stylePlace = { font: '26px Arial', fill: '#400080', align: 'center'};
+        let styleLabel = { font: '26px Arial', fill: '#000080', align: 'center'};
+        let styleMenu = { font: '30px Arial', fill: '#000000', align: 'center'};
         
         //Floor and road
         startX = 66; //Initial kid and place position
@@ -261,18 +261,18 @@ var gameCircleOne = {
         
         placeDistance = 156; //Distance between places
         blockSize = 60;
-        for(var i=0;i<9;i++){
+        for(let i=0;i<9;i++){
             game.add.image(i*100, 501, 'floor');
         }
-        var road = game.add.image(47, 515, 'road');
+        let road = game.add.image(47, 515, 'road');
         road.scale.setTo(1.01,0.94);
         if(levelType=='A'){
             road.inputEnabled = true;
             road.events.onInputDown.add(this.func_setPlace, {beep: beepSound}); //enabling input for tablets
         }
         
-        for(var p=0;p<=5;p++){// Places
-            var place = game.add.image(66+p*placeDistance, 526, 'place_a');
+        for(let p=0;p<=5;p++){// Places
+            let place = game.add.image(66+p*placeDistance, 526, 'place_a');
             place.anchor.setTo(0.5);
             place.scale.setTo(0.3);
             game.add.text(66+p*placeDistance, 560, p , stylePlace).anchor.setTo(0.5); 
@@ -295,7 +295,7 @@ var gameCircleOne = {
                 
         //generator
         //Circles and fractions
-        var maxBlocks = levelPosition+1; //Maximum blocks according to difficulty
+        let maxBlocks = levelPosition+1; //Maximum blocks according to difficulty
         if(levelType=='B' || levelOperator=='Mixed') maxBlocks = 6;
         blocks = game.add.group(); //Fraction arrays
         numBlocks = game.rnd.integerInRange(levelPosition, maxBlocks); //Number of blocks
@@ -314,17 +314,17 @@ var gameCircleOne = {
         fractionIndex = -1; //Index of clicked fraction (game B)
         numPlus = game.rnd.integerInRange(1, numBlocks-1);
         
-        for(var p=0;p<numBlocks;p++){
+        for(let p=0;p<numBlocks;p++){
 
-            var portion = game.rnd.integerInRange(1, levelDifficulty); //Portion of the circle, according to difficulty
+            let portion = game.rnd.integerInRange(1, levelDifficulty); //Portion of the circle, according to difficulty
             detail += portion+",";
             
             if(portion==levelDifficulty){
                 hasFigure = true;
             }
             
-            var direction = '';
-            var lineColor = '';
+            let direction = '';
+            let lineColor = '';
             if(levelOperator=='Mixed'){
                 if(p<=numPlus){
                     direction = 'Right';
@@ -333,8 +333,8 @@ var gameCircleOne = {
                     direction = 'Left';
                     lineColor = 0xb30000;
                 }
-                /*var directions = ['Right','Left'];
-                var rndIndex = game.rnd.integerInRange(0, 1);
+                /*let directions = ['Right','Left'];
+                let rndIndex = game.rnd.integerInRange(0, 1);
                 direction = directions[rndIndex];
                 if(rndIndex==0) lineColor = 0x31314e;
                 else lineColor = 0xb30000;*/
@@ -347,7 +347,7 @@ var gameCircleOne = {
             }
             
             blockTraceColor[p] = lineColor;
-            var block = game.add.graphics(startX, 490-p*blockSize);
+            let block = game.add.graphics(startX, 490-p*blockSize);
                 block.anchor.setTo(0.5,0.5);
 
                 block.lineStyle(2, lineColor);
@@ -364,28 +364,28 @@ var gameCircleOne = {
                 blockAngle.push(360);
 
                 if(levelLabel){
-                    var labelX = startX;
+                    let labelX = startX;
                     if(levelOperator=='Minus') labelX -= 65;
                     else labelX += 65;
-                    var label = game.add.text(labelX, 490-p*blockSize, portion , styleLabel);
+                    let label = game.add.text(labelX, 490-p*blockSize, portion , styleLabel);
                     label.anchor.setTo(0.5, 0.5);
                     blockLabel.add(label);
                 }
             }else{
-                var distance = 360/portion+5;
+                let distance = 360/portion+5;
                 block.arc(0, 0, blockSize/2, game.math.degToRad(distance), 0, true);
 
                 blockDistance.push(Math.floor(placeDistance/portion));
                 blockAngle.push(distance);
 
                 if(levelLabel){
-                    var labelX = startX;
+                    let labelX = startX;
                     if(levelOperator=='Minus') labelX -= 65;
                     else labelX += 65;
-                    var separator = game.add.sprite(labelX, 485-p*blockSize, 'separator');
+                    let separator = game.add.sprite(labelX, 485-p*blockSize, 'separator');
                     separator.anchor.setTo(0.5, 0.5);
                     blockSeparator.add(separator);
-                    var label = game.add.text(labelX, 488-p*blockSize, '1\n'+portion , styleLabel);
+                    let label = game.add.text(labelX, 488-p*blockSize, '1\n'+portion , styleLabel);
                     label.anchor.setTo(0.5, 0.5);
                     blockLabel.add(label);
                 }
@@ -425,7 +425,7 @@ var gameCircleOne = {
         if(levelType=='B'){
             balloonPlace = startX;
             endIndex = game.rnd.integerInRange(numPlus, numBlocks);
-            for(var i=0;i<endIndex;i++){
+            for(let i=0;i<endIndex;i++){
                 if(blockDirection[i]=='Right')
                     balloonPlace += blockDistance[i];
                 else if(blockDirection[i]=='Left')
@@ -510,7 +510,7 @@ var gameCircleOne = {
         //Start animation
         if(animate){
             
-            var color = '';
+            let color = '';
             if(blockDirection[curBlock]=='Right'){
                 kid_walk.x+=2;
                 color = 'rgba(0, 51, 153, 1)';
@@ -521,7 +521,7 @@ var gameCircleOne = {
             
             trace.rect(kid_walk.x, 526, 2, 2, color);
             
-            for(var i=0;i<numBlocks;i++){ //Moving every block
+            for(let i=0;i<numBlocks;i++){ //Moving every block
                 if(blockDirection[curBlock]=='Right'){
                     blocks.children[i].x +=2;
                 }else{
@@ -636,7 +636,7 @@ var gameCircleOne = {
     func_overCircle: function(){
         
         if(!clicked){
-            for(var i=0;i<numBlocks;i++){
+            for(let i=0;i<numBlocks;i++){
                 if(i<=this.indice){
                     blocks.children[i].alpha = 1;
                 }else{
@@ -649,7 +649,7 @@ var gameCircleOne = {
 
     func_outCircle: function(){
         if(!clicked){
-            for(var i=0;i<=this.indice;i++){
+            for(let i=0;i<=this.indice;i++){
                 blocks.children[i].alpha = 0.5;
             }
         }
@@ -659,9 +659,9 @@ var gameCircleOne = {
     func_clickCircle: function(){
 
         if(!clicked){
-            var minusBlocks = 0;
+            let minusBlocks = 0;
             
-            for(var i=0;i<numBlocks;i++){
+            for(let i=0;i<numBlocks;i++){
                 if(i<=this.indice){
                     fractionIndex = this.indice;
                     blocks.children[i].alpha = 1;
@@ -723,14 +723,14 @@ var gameCircleOne = {
 
     func_postScore: function (){
     
-        var abst = "numCircles:" + numBlocks + ", valCircles: " + detail + " balloonX: " + basket.x + ", selIndex: " + fractionIndex;
+        let abst = "numCircles:" + numBlocks + ", valCircles: " + detail + " balloonX: " + basket.x + ", selIndex: " + fractionIndex;
 
-        var lang_str = "pt_BR"; //TODO NAO esta pegando a lingua definida pelo usuario!
+        let lang_str = "pt_BR"; //TODO NAO esta pegando a lingua definida pelo usuario!
 
-        var hr = new XMLHttpRequest();
+        let hr = new XMLHttpRequest();
         // Create some variables we need to send to our PHP file
-        var url = "php/save.php";
-        var vars = "s_ip=" + hip + "&s_name=" + username + "&s_lang=" + lang + "&s_game=" + levelShape + "&s_mode=" + levelType;
+        let url = "php/save.php";
+        let 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;
         
@@ -740,7 +740,7 @@ var gameCircleOne = {
             if(debugMode) console.log(hr);
 
             if(hr.readyState == 4 && hr.status == 200) {
-                var return_data = hr.responseText;
+                let return_data = hr.responseText;
                 if(debugMode) console.log(return_data);
             }
         }
@@ -753,11 +753,11 @@ var gameCircleOne = {
     func_viewHelp: function(){
 
         if(!clicked){
-            var pointer;
+            let pointer;
             if(levelType=='A'){
-                var pointer = game.add.image(endPosition, 490, 'pointer');
+                let pointer = game.add.image(endPosition, 490, 'pointer');
             }else{
-                var pointer = game.add.image(blocks.children[endIndex-1].x, blocks.children[endIndex-1].y-blockSize/2, 'pointer');
+                let pointer = game.add.image(blocks.children[endIndex-1].x, blocks.children[endIndex-1].y-blockSize/2, 'pointer');
             }
             pointer.anchor.setTo(0.5, 0);
             pointer.alpha = 0.7;
@@ -767,8 +767,8 @@ var gameCircleOne = {
     
     func_checkOverlap: function (spriteA, spriteB) {
 
-        var xA = spriteA.x;
-        var xB = spriteB.x;
+        let xA = spriteA.x;
+        let xB = spriteB.x;
                 
         if(Math.abs(xA-xB)>14){
             return false;
@@ -782,7 +782,7 @@ var gameCircleOne = {
 
 /****************************** END ****************************/
 
-var endCircleOne = {
+let endCircleOne = {
     
     create: function() {  
         
@@ -795,18 +795,18 @@ var endCircleOne = {
         game.add.image(110, 85, 'cloud').scale.setTo(0.8);
         
         // Styles for labels
-        var stylePlace = { font: '26px Arial', fill: '#400080', align: 'center'};
-        var styleLabel = { font: '26px Arial', fill: '#000080', align: 'center'};
-        var styleMenu = { font: '30px Arial', fill: '#000000', align: 'center'};
+        let stylePlace = { font: '26px Arial', fill: '#400080', align: 'center'};
+        let styleLabel = { font: '26px Arial', fill: '#000080', align: 'center'};
+        let styleMenu = { font: '30px Arial', fill: '#000000', align: 'center'};
         
         //Floor
-        for(var i=0;i<9;i++){
+        for(let i=0;i<9;i++){
             game.add.image(i*100, 501, 'floor');
         }
         
         // Progress bar
-        for(var p=1;p<=5;p++){
-            var block = game.add.image(660+(p-1)*30, 10, 'block');
+        for(let p=1;p<=5;p++){
+            let block = game.add.image(660+(p-1)*30, 10, 'block');
             block.scale.setTo(2, 1); //Scaling to double width
         }
         game.add.text(820, 10, '100%', styleMenu);
@@ -822,7 +822,7 @@ var endCircleOne = {
         this.kid = game.add.sprite(0, -152 , 'kid_run');
         this.kid.anchor.setTo(0.5,0.5);
         this.kid.scale.setTo(0.7);
-        var walk = this.kid.animations.add('walk', [0,1,2,3,4,5,6,7,8,9,10,11]);
+        let walk = this.kid.animations.add('walk', [0,1,2,3,4,5,6,7,8,9,10,11]);
         
         //globo
         this.balloon = game.add.sprite(0, -260, 'balloon');

File diff suppressed because it is too large
+ 0 - 4
js/jquery.min.js


+ 28 - 28
js/map.js

@@ -1,6 +1,6 @@
 
 /*
-    var mapState = {
+    let mapState = {
         create: function(){},
         update: function(){},
         ---------------------------- end of phaser functions
@@ -8,7 +8,7 @@
     }
 */
 
-var mapState = {
+let mapState = {
 
     create: function() {
 
@@ -32,15 +32,15 @@ var mapState = {
                                     this.menuStateString,false);
         
         // Styles for labels
-        var stylePlace = { font: '26px Arial', fill: '#ffffff', align: 'center'};
-        var styleMenu = { font: '30px Arial', fill: '#000000', align: 'center'};
+        const stylePlace = { font: '26px Arial', fill: '#ffffff', align: 'center'};
+        const styleMenu = { font: '30px Arial', fill: '#000000', align: 'center'};
         
         // Progress bar
-        var percentText = passedLevels*25;
-        var percentBlocks = passedLevels;
+        let percentText = passedLevels*25;
+        let percentBlocks = passedLevels;
 
-        for(var p=0;p<percentBlocks;p++){
-            var block = game.add.image(660+p*37.5, 10, 'block');
+        for(let p=0;p<percentBlocks;p++){
+            let block = game.add.image(660+p*37.5, 10, 'block');
                 block.scale.setTo(2.6, 1);
         }
 
@@ -56,61 +56,61 @@ var mapState = {
         
         if(this.gameStateString=="gameSquareOne"){
         	//Garage
-	        var garage = game.add.image(this.points.x[0], this.points.y[0], 'garage');
+	        let garage = game.add.image(this.points.x[0], this.points.y[0], 'garage');
 	        garage.scale.setTo(0.4);
 	        garage.anchor.setTo(0.5, 1);
 	         //Farm
-	        var farm = game.add.image(this.points.x[5], this.points.y[5], 'farm');
+	        let farm = game.add.image(this.points.x[5], this.points.y[5], 'farm');
 	        farm.scale.setTo(0.6);
 	        farm.anchor.setTo(0.1, 0.7);
         }else{
 	      	//House
-	        var house = game.add.image(this.points.x[0], this.points.y[0], 'house');
+	        let house = game.add.image(this.points.x[0], this.points.y[0], 'house');
 	        house.scale.setTo(0.7);
 	        house.anchor.setTo(0.7, 0.8);
 	         //School
-	        var school = game.add.image(this.points.x[5], this.points.y[5], 'school');
+	        let school = game.add.image(this.points.x[5], this.points.y[5], 'school');
 	        school.scale.setTo(0.35);
 	        school.anchor.setTo(0.2, 0.7);
 	    }
 
          //Trees and Rocks
         
-        this.rocks = {
+        const rocks = {
              'x': [156, 275, 276, 441, 452, 590, 712],
              'y': [309, 543, 259, 156, 419, 136, 316]
         }
 
-        this.r_types = [1, 1, 2, 1, 2, 2, 2];
+        const r_types = [1, 1, 2, 1, 2, 2, 2];
         
-        for(var i=0; i<this.r_types.length; i++){
-            if(this.r_types[i]==1){
-                var sprite = game.add.image(this.rocks.x[i], this.rocks.y[i], 'rock');
+        for(let i=0; i<r_types.length; i++){
+            if(r_types[i]==1){
+                let sprite = game.add.image(rocks.x[i], rocks.y[i], 'rock');
                 sprite.scale.setTo(0.32);
                 sprite.anchor.setTo(0.5, 0.95);
-            }else if(this.r_types[i]==2){
-                var sprite = game.add.image(this.rocks.x[i], this.rocks.y[i], 'birch');
+            }else if(r_types[i]==2){
+                let sprite = game.add.image(rocks.x[i], rocks.y[i], 'birch');
                 sprite.scale.setTo(0.4);
                 sprite.anchor.setTo(0.5, 0.95);
             }
         }
 
-        this.trees = {
+        const trees = {
              'x': [105, 214, 354, 364, 570, 600, 740, 779],
              'y': [341, 219, 180, 520, 550, 392, 488, 286]
         }
 
-        this.t_types = [2, 4, 3, 4, 1, 2, 4, 4];
+        const t_types = [2, 4, 3, 4, 1, 2, 4, 4];
         
-        for(var i=0; i<this.t_types.length; i++){
-            var sprite = game.add.image(this.trees.x[i], this.trees.y[i], 'tree'+this.t_types[i]);
+        for(let i=0; i<t_types.length; i++){
+            let sprite = game.add.image(trees.x[i], trees.y[i], 'tree'+t_types[i]);
             sprite.scale.setTo(0.6);
             sprite.anchor.setTo(0.5, 0.95);
         }
         
         // places
-        for (var p = 1; p < this.points.x.length -1; p++){
-            var place;
+        for (let p = 1; p < this.points.x.length -1; p++){
+            let place;
             if(p<levelPosition){
                 place = game.add.image(this.points.x[p], this.points.y[p], 'place_b');
             }else if (levelMove && p==levelPosition){
@@ -120,11 +120,11 @@ var mapState = {
             }
             place.anchor.setTo(0.5, 0.5);
             place.scale.setTo(0.3);
-            var sign = game.add.image(this.points.x[p]-20, this.points.y[p]-60, 'sign');
+            let sign = game.add.image(this.points.x[p]-20, this.points.y[p]-60, 'sign');
             sign.anchor.setTo(0.5, 1);
             sign.scale.setTo(0.4);
             if(p>0 && p<this.points.x.length-1){
-                var text = game.add.text(this.points.x[p]-23, this.points.y[p]-84, p, stylePlace);
+                let text = game.add.text(this.points.x[p]-23, this.points.y[p]-84, p, stylePlace);
                 text.anchor.setTo(0.35, 0.5);
             }
         }
@@ -132,7 +132,7 @@ var mapState = {
         if(this.gameStateString=="gameSquareOne"){
 	    	this.character = game.add.sprite(this.points.x[levelPosition], this.points.y[levelPosition], 'tractor');
 
-	        var walk = this.character.animations.add('walk',[0,1,2,3,4]);
+	        let walk = this.character.animations.add('walk',[0,1,2,3,4]);
 	        this.character.animations.play('walk', 5, true);
 	        this.character.angle -= 25;
         }else{

+ 12 - 12
js/menu.js

@@ -1,6 +1,6 @@
 
 /*
-    var menuState = {
+    let menuState = {
         create: function(){},
         ---------------------------- end of phaser functions
         func_loadGame: function(){},
@@ -9,7 +9,7 @@
     }
 */
 
-var menuState = {
+let menuState = {
 
     inputStartPosition: null,
     inputEndPosition: null,
@@ -26,7 +26,7 @@ var menuState = {
     create: function() {
         
         if(loadAssets.levelSpriteList.length > 8){
-            var aux = loadAssets.levelSpriteList.length-8;
+            let aux = loadAssets.levelSpriteList.length-8;
             this.extraWidth = (aux%2==0) ? (aux/2)*235 : ((aux+1)/2)*235;
         }else{
             this.extraWidth = 0;
@@ -36,7 +36,7 @@ var menuState = {
         this.game.world.setBounds(0, 0, this.game.world.width + this.extraWidth, this.game.world.height);
      	  
         // Floor
-        for(var i=0;i<this.game.world.width/100;i++){
+        for(let i=0;i<this.game.world.width/100;i++){
             game.add.image(i*100, 501, 'floor');
         }
         // LABELS
@@ -46,12 +46,12 @@ var menuState = {
         this.player_info.anchor.setTo(0.5,0.5);
 
         // Title : Select a game
-        var style = { font: "32px Arial", fill: "#00804d", align: "center" };
+        const style = { font: "32px Arial", fill: "#00804d", align: "center" };
         this.title = game.add.text(this.game.world.centerX - this.extraWidth/2, 80, lang.menu_title, style);
         this.title.anchor.setTo(0.5,0.5);
 
         // Subtitle : Game mode 
-        var style_game = { font: "27px Arial", fill: "#003cb3", align: "center" };
+        const style_game = { font: "27px Arial", fill: "#003cb3", align: "center" };
         this.lbl_game = game.add.text(this.game.world.centerX - this.extraWidth/2, 110, "", style_game);
         this.lbl_game.anchor.setTo(0.5,0.5);
 
@@ -64,10 +64,10 @@ var menuState = {
                                      false,false);
         
         // Game buttons
-		var x = -350;
-		var y = -70;
-        var menuObjList = [];
-		for(var i=0; i<loadAssets.levelSpriteList.length; i++){
+		let x = -350;
+		let y = -70;
+        let menuObjList = [];
+		for(let i=0; i<loadAssets.levelSpriteList.length; i++){
 			menuObjList[i] = game.add.sprite(defaultWidth/2 + x, this.game.world.centerY + y, 'game'+i);
 			menuObjList[i].anchor.setTo(0.5, 0.5);
 	        menuObjList[i].inputEnabled = true;
@@ -176,8 +176,8 @@ var menuState = {
 
     func_showTitle: function(){
         
-        var title = "";
-        var type = "";
+        let title = "";
+        let type = "";
         
         if(this.levelType==1){
             type = "I";

js/phaser.js → js/phaser/phaser.js


File diff suppressed because it is too large
+ 1 - 0
js/phaser/phaser.map


js/phaser.min.js → js/phaser/phaser.min.js


+ 25 - 26
js/preMenu.js

@@ -1,25 +1,25 @@
 
 /*
-    var langState = {
+    let langState = {
         create: function(){},
         --------------------------------------- end of phaser functions
         func_setLang: function(){} //calls loadState
     };
     
-    var loadState = {
+    let loadState = {
         preload: function(){},
         create: function(){} //calls nameState
         -------------------------------------- end of phaser functions
     };
         
-    var nameState = {
+    let nameState = {
         create: function(){},
         ------------------------------------------------ end of phaser functions
         func_checkEmptyName: function(){}
         func_savename: function(){} //calls menu.js -> menuState
     };
 
-    var buttonSettings = {
+    let buttonSettings = {
         func_addButtons: function(_,_,_,_,_,_,_,_,_){},
         loadState: function(){}
     };
@@ -27,7 +27,7 @@
 
 // "choose language" screen
 
-var langState = {
+let langState = {
 
     create: function() {
 
@@ -35,7 +35,7 @@ var langState = {
 
         // AUX
 
-        var style = { font: '28px Arial', fill: '#00804d', align: 'center' };
+        const style = { font: '28px Arial', fill: '#00804d', align: 'center' };
 
         // AUDIO
 
@@ -49,16 +49,16 @@ var langState = {
         
         // LANGUAGES
 
-        var flagObjList = [];
-        var langNameList= ['FRAÇÕES  ', 'FRAZIONI  ',   'FRACTIONS  ',  'FRACCIONES  ', 'FRACTIONS  '   ];
-        var flagList    = ['flag_BR',   'flag_IT',      'flag_US',      'flag_PE',      'flag_FR'       ];
-        var langList    = ['pt_BR',     'it_IT',        'en_US',        'es_PE',        'fr_FR'         ];
-        var x1List = [-220, -220, -220,  200, 200];
-        var x2List = [-120, -120, -120,  300, 300];
-        var yList  = [-180,    0,  180, -100, 100];
+        let flagObjList = [];
+        const langNameList= ['FRAÇÕES  ', 'FRAZIONI  ',   'FRACTIONS  ',  'FRACCIONES  ', 'FRACTIONS  '   ];
+        const flagList    = ['flag_BR',   'flag_IT',      'flag_US',      'flag_PE',      'flag_FR'       ];
+        const langList    = ['pt_BR',     'it_IT',        'en_US',        'es_PE',        'fr_FR'         ];
+        const x1List = [-220, -220, -220,  200, 200];
+        const x2List = [-120, -120, -120,  300, 300];
+        const yList  = [-180,    0,  180, -100, 100];
         
-        for(var i=0; i<langList.length; i++){
-            var titleList = game.add.text(this.game.world.centerX + x1List[i], this.game.world.centerY + yList[i], langNameList[i], style);
+        for(let i=0; i<langList.length; i++){
+            let titleList = game.add.text(this.game.world.centerX + x1List[i], this.game.world.centerY + yList[i], langNameList[i], style);
             titleList.anchor.setTo(1, 0.5);
 
             flagObjList[i] = game.add.sprite(this.game.world.centerX + x2List[i], this.game.world.centerY + yList[i], flagList[i]);       
@@ -84,12 +84,12 @@ var langState = {
 };
 
 // "loading" screen and load json dictionary
-var loadState = {
+let loadState = {
     
     preload: function() {
         
         // Displaying the progress bar
-        var progressBar = game.add.sprite(game.world.centerX, game.world.centerY, 'progressBar');
+        let progressBar = game.add.sprite(game.world.centerX, game.world.centerY, 'progressBar');
         progressBar.anchor.setTo(0.5, 0.5);
         game.load.setPreloadSprite(progressBar);
         
@@ -115,18 +115,17 @@ var loadState = {
 };
 
 // "username" screen
-var nameState = {
+let nameState = {
 
     create: function() {
                     
         // AUX
 
-        var style = { font: '30px Arial', fill: '#00804d', align: 'center' };
-        var styleName = { font: '44px Arial', fill: '#000000', align: 'center' };
+        const style = { font: '30px Arial', fill: '#00804d', align: 'center' };
         
         // title
 
-        var title = game.add.text(this.game.world.centerX, this.game.world.centerY - 100, lang.insert_name, style);
+        let title = game.add.text(this.game.world.centerX, this.game.world.centerY - 100, lang.insert_name, style);
         title.anchor.setTo(0.5);
         
         errorEmptyName = game.add.text(this.game.world.centerX, this.game.world.centerY - 70, "", {font: '18px Arial', fill: '#330000', align: 'center'});
@@ -134,7 +133,7 @@ var nameState = {
 
         // "READY" button
         
-        var btn = game.add.graphics(this.game.world.centerX - 84, this.game.world.centerY + 70);
+        let btn = game.add.graphics(this.game.world.centerX - 84, this.game.world.centerY + 70);
         btn.lineStyle(1, 0x293d3d);
         btn.beginFill(0x3d5c5c);
         btn.drawRect(0, 0, 168, 60);
@@ -147,12 +146,12 @@ var nameState = {
         btn.events.onInputOver.add(function(){ btn.alpha=0.4 });
         btn.events.onInputOut.add(function(){ btn.alpha=0.5 });
         
-        var ready = game.add.text(this.game.world.centerX + 1, this.game.world.centerY + 102, lang.ready, { font: '34px Arial', fill: '#f0f5f5', align: 'center' });
+        let ready = game.add.text(this.game.world.centerX + 1, this.game.world.centerY + 102, lang.ready, { font: '34px Arial', fill: '#f0f5f5', align: 'center' });
         ready.anchor.setTo(0.5);      
 
         document.getElementById("text-field-div").style.visibility = "visible";
         document.getElementById("name_id").addEventListener('keypress', function(e){
-            var keycode = e.keycode ? e.keycode : e.which; 
+            let keycode = e.keycode ? e.keycode : e.which; 
             //se apertar enter vai para ready, assim como o botão
             if(keycode == 13){
                 nameState["func_checkEmptyName"]();
@@ -193,7 +192,7 @@ var nameState = {
 
 };
 
-var buttonSettings = {
+let buttonSettings = {
 
     m_info_left: null,
 
@@ -290,7 +289,7 @@ var buttonSettings = {
     changeRightButtonX: function(newWidth){
         this.m_info_right.x = newWidth - 10;
         this.m_audio.x = newWidth - 50 - 10;
-        console.log(this.m_audio.x+" "+newWidth);
+        if(debugMode) console.log(this.m_audio.x+" "+newWidth);
         this.m_world.x = newWidth - 50 - 50 - 10;
     },
 

+ 99 - 99
js/squareOne.js

@@ -1,12 +1,12 @@
 
 /*
-    var menuSquareOne = {
+    let menuSquareOne = {
         create: function(){},
         ---------------------------- end of phaser functions
         func_loadMap: function(){}
     };
 
-    var gameSquareOne = {
+    let gameSquareOne = {
         create: function(){},
         update: function(){},
         ---------------------------- end of phaser functions
@@ -21,7 +21,7 @@
             //func_getRndDivisor: function(){}
     };
 
-    var endSquareOne = {
+    let endSquareOne = {
         create: function(){},
         update: function(){},
         ---------------------------- end of phaser functions
@@ -33,7 +33,7 @@
 
 /****************************** MENU ****************************/
 
-var menuSquareOne = {
+let menuSquareOne = {
 	
     create: function() {
           
@@ -44,47 +44,47 @@ var menuSquareOne = {
                                     false,false);
         
         // Title
-        var style = { font: '28px Arial', fill: '#00804d'};
-        var title = game.add.text(game.world.centerX, 40, lang.game_menu_title, style);
+        let style = { font: '28px Arial', fill: '#00804d'};
+        let title = game.add.text(game.world.centerX, 40, lang.game_menu_title, style);
         title.anchor.setTo(0.5, 0.5);
         
         //SETTING DIFFICULTY LEVELS
 
-        var maxHeight = 120; //Max height of a stair
-        var stairHeight = 40; //height growth of a stair
-        var stairWidth = 100; //Width of a stair
-        var startStair = 320;
-        var startSymbol = 180; 
-        var startSquare = (startSymbol/2)+startStair+stairWidth*3;
+        let maxHeight = 120; //Max height of a stair
+        let stairHeight = 40; //height growth of a stair
+        let stairWidth = 100; //Width of a stair
+        let startStair = 320;
+        let startSymbol = 180; 
+        let startSquare = (startSymbol/2)+startStair+stairWidth*3;
         
         //First stairs, plus, 3 levels, blue square
 
-        var blueSquare = game.add.graphics(startSquare, 175);
+        let blueSquare = game.add.graphics(startSquare, 175);
             blueSquare.anchor.setTo(0.5,0.5);
             blueSquare.lineStyle(2, 0x31314e);
             blueSquare.beginFill(0xefeff5);
             blueSquare.drawRect(0, 0, 80, 40);
             blueSquare.endFill();
         
-        var plusTractorIcon = game.add.sprite(startSymbol+30, 215, 'tractor_green');
+        let 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');
+        let 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 = [];
+        let stairsPlus = [];
 
-        for(var i=1;i<=3;i++){
+        for(let i=1;i<=3;i++){
             //stair
-            var x1 = startStair+(stairWidth*(i-1));
-            var y1 = 135+maxHeight-i*stairHeight;
-            var x2 = stairWidth;//x1 + 40;
-            var y2 = stairHeight*i;//y1 + 24;
+            let x1 = startStair+(stairWidth*(i-1));
+            let y1 = 135+maxHeight-i*stairHeight;
+            let x2 = stairWidth;//x1 + 40;
+            let y2 = stairHeight*i;//y1 + 24;
             
             stairsPlus[i] = game.add.graphics(0, 0);
             stairsPlus[i].lineStyle(1, 0xFFFFFF, 1);
@@ -100,41 +100,41 @@ var menuSquareOne = {
             stairsPlus[i].events.onInputOut.add(function (item) { item.alpha=1; }, this);
             
             //label
-            var xl = x1+stairWidth/2; //x label
-            var yl = y1+(stairHeight*i)/2; //y label
-            var label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' });
+            let xl = x1+stairWidth/2; //x label
+            let yl = y1+(stairHeight*i)/2; //y label
+            let label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' });
                 label.anchor.setTo(0.5, 0.4);
         }
         
         //Second stairs, minus, 3 levels, red Square
 
-        var redSquare = game.add.graphics(startSquare, 330);
+        let redSquare = game.add.graphics(startSquare, 330);
             redSquare.anchor.setTo(0.5,0.5);
             redSquare.lineStyle(2, 0xb30000);
             redSquare.beginFill(0xefeff5);
             redSquare.drawRect(0, 0, 80, 40);
             redSquare.endFill();
 
-        var minusTractorIcon = game.add.sprite(startSymbol+70, 370, 'tractor_red');
+        let 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 minusArrowIcon = game.add.sprite(startSymbol, 370, 'h_arrow');
+        let 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 = [];
+        let stairsMinus = [];
 
-        for(var i=1;i<=3;i++){
+        for(let i=1;i<=3;i++){
             //stair
-            var x1 = startStair+(stairWidth*(i-1));
-            var y1 = 285+maxHeight-i*stairHeight;
-            var x2 = stairWidth;//x1 + 40;
-            var y2 = stairHeight*i;//y1 + 24;
+            let x1 = startStair+(stairWidth*(i-1));
+            let y1 = 285+maxHeight-i*stairHeight;
+            let x2 = stairWidth;//x1 + 40;
+            let y2 = stairHeight*i;//y1 + 24;
             
             stairsMinus[i] = game.add.graphics(0, 0);
             stairsMinus[i].lineStyle(1, 0xFFFFFF, 1);
@@ -150,9 +150,9 @@ var menuSquareOne = {
             stairsMinus[i].events.onInputOut.add(function (item) { item.alpha=1; }, this);
             
             //label
-            var xl = x1+stairWidth/2; //x label
-            var yl = y1+(stairHeight*i)/2; //y label
-            var label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' });
+            let xl = x1+stairWidth/2; //x label
+            let yl = y1+(stairHeight*i)/2; //y label
+            let label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' });
                 label.anchor.setTo(0.5, 0.4);
         } 
 
@@ -179,7 +179,7 @@ var menuSquareOne = {
 
 /****************************** GAME ****************************/
 
-var gameSquareOne = {
+let gameSquareOne = {
 
     create: function() {  
         
@@ -205,18 +205,18 @@ var gameSquareOne = {
         game.add.image(110, 85, 'cloud').scale.setTo(0.8);
                 
         // Styles for labels
-        var stylePlace = { font: '26px Arial', fill: '#400080', align: 'center'};
-        var styleLabel = { font: '26px Arial', fill: '#000080', align: 'center'};
-        var styleFraction = { font: '15px Arial', fill: '#000080', align: 'center'};
-        var styleMenu = { font: '30px Arial', fill: '#000000', align: 'center'};
+        let stylePlace = { font: '26px Arial', fill: '#400080', align: 'center'};
+        let styleLabel = { font: '26px Arial', fill: '#000080', align: 'center'};
+        let styleFraction = { font: '15px Arial', fill: '#000080', align: 'center'};
+        let styleMenu = { font: '30px Arial', fill: '#000000', align: 'center'};
         
         //Floor and road
-        var startX = 170; //Initial tractor and place position
+        let startX = 170; //Initial tractor and place position
         if(levelOperator=='Minus') startX = 730;
         startX = startX; //Workaround for initial position inside update
-        var blockWidth = 80; //Width of blocks and floor spaces
-        var blockHeight = 40; //Height of blocks and floor spaces
-        for(var i=0;i<9;i++){
+        let blockWidth = 80; //Width of blocks and floor spaces
+        let blockHeight = 40; //Height of blocks and floor spaces
+        for(let i=0;i<9;i++){
             game.add.image(i*100, 501, 'floor');
         }
                 
@@ -231,7 +231,7 @@ var gameSquareOne = {
         moveEnd = 140; //Move end counter
                 
         //tractor
-        var tractorAlign = -80;
+        let tractorAlign = -80;
         if(levelOperator=='Minus'){
             tractorAlign *= -1;
         } 
@@ -281,15 +281,15 @@ var gameSquareOne = {
         
         hasFigure = false;
 
-        for(var p=0;p<numBlocks;p++){
+        for(let p=0;p<numBlocks;p++){
 
-            var portion = game.rnd.integerInRange(1, levelDifficulty); //Portion of the square, according to difficulty
+            let portion = game.rnd.integerInRange(1, levelDifficulty); //Portion of the square, according to difficulty
             if(portion==3) detail+= "4,";
             else detail += portion+",";
             
             if(portion==levelDifficulty) hasFigure = true;
-            var direction = '';
-            var lineColor = '';
+            let direction = '';
+            let lineColor = '';
             
             if(levelOperator=='Plus'){
                 direction = 'Right';    
@@ -300,7 +300,7 @@ var gameSquareOne = {
             }
             
             //blocks close to tractor
-            var block = game.add.graphics(startX, 460-p*blockHeight);
+            let block = game.add.graphics(startX, 460-p*blockHeight);
                 block.anchor.setTo(0.5, 0.5);
                 block.lineStyle(2, lineColor);
                 block.beginFill(0xefeff5);
@@ -314,31 +314,31 @@ var gameSquareOne = {
                 //blockAngle.push(360);
 
                 if(levelLabel){
-                    var labelX = startX;
+                    let labelX = startX;
                     if(levelOperator=='Minus') labelX -= (15+blockWidth);
                     else labelX += blockWidth+15;
-                    var label = game.add.text(labelX, 480-p*blockHeight, portion , styleLabel);
+                    let label = game.add.text(labelX, 480-p*blockHeight, portion , styleLabel);
                     label.anchor.setTo(0.5, 0.5);
                     blockLabel.add(label);
                 }
             }else{
                 if(portion==3) portion = 4;
                 
-                var distance = blockWidth/portion;
+                let distance = blockWidth/portion;
                 
                 block.drawRect(0, 0, distance, blockHeight);
                 
                 blockDistance.push(distance);
 
                 if(levelLabel){
-                    var labelX = startX;
+                    let labelX = startX;
                     if(levelOperator=='Minus') labelX -= (15+distance);
                     else labelX += 15+distance;
-                    var separator = game.add.sprite(labelX, 480-p*blockHeight, 'separator');
+                    let separator = game.add.sprite(labelX, 480-p*blockHeight, 'separator');
                     separator.scale.setTo(0.6);
                     separator.anchor.setTo(0.5, 0.5);
                     blockSeparator.add(separator);
-                    var label = game.add.text(labelX, 483-p*blockHeight, '1\n'+portion , styleFraction);
+                    let label = game.add.text(labelX, 483-p*blockHeight, '1\n'+portion , styleFraction);
                     label.anchor.setTo(0.5, 0.5);
                     blockLabel.add(label);
                 }
@@ -384,8 +384,8 @@ var gameSquareOne = {
         
         //If game is type B, selectiong a random block floor place
         if(levelType=='B'){
-            var end = game.rnd.integerInRange(1, numBlocks);
-            for(var i=0;i<end;i++){
+            let end = game.rnd.integerInRange(1, numBlocks);
+            for(let i=0;i<end;i++){
                 if(blockDirection[i]=='Right')
                     arrowPlace += blockDistance[i];
                 else if(blockDirection[i]=='Left')
@@ -396,15 +396,15 @@ var gameSquareOne = {
         //Selectable floor
         floorCount = 8*levelDifficulty;
         
-        var widFloor = blockWidth/levelDifficulty;
+        let widFloor = blockWidth/levelDifficulty;
 
         if(levelDifficulty==3){
             floorCount = 8*4;
             widFloor = blockWidth/4;
         }
         
-        for(var i = 0; i < floorCount; i++){
-            var posX = startX;
+        for(let i = 0; i < floorCount; i++){
+            let posX = startX;
             
             if(levelOperator=='Minus') posX -= (blockWidth + i*widFloor);
             else posX += (blockWidth + i*widFloor);
@@ -426,7 +426,7 @@ var gameSquareOne = {
             }
 
             // blocks on the floor
-            var block = game.add.graphics(posX, 500);
+            let block = game.add.graphics(posX, 500);
                 block.anchor.setTo(0.5, 0);
                 block.lineStyle(0.9, 0xffffff);
                 block.beginFill(0xa8c0e6);
@@ -446,8 +446,8 @@ var gameSquareOne = {
             floorBlocks.add(block);     
         }
         
-        for(var i=0;i<=8;i++){
-            var posX = startX;
+        for(let i=0;i<=8;i++){
+            let posX = startX;
             if(levelOperator=='Minus')posX -= ((9-i)*blockWidth);
             else posX+=((i+1)*blockWidth);
             
@@ -480,7 +480,7 @@ var gameSquareOne = {
                     //Follow mouse
                     if (game.physics.arcade.distanceToPointer(arrow, game.input.activePointer) > 8 )
 				    {	
-                    	var xPos = game.input.mousePointer.x;
+                    	let xPos = game.input.mousePointer.x;
 			            //set left limit to the arrow  
                     	if  (xPos < 250){
                     		xPos = 250;
@@ -500,7 +500,7 @@ var gameSquareOne = {
                 tractor.x-=2;
             }
                         
-            for(var i=0;i<numBlocks;i++){ //Moving every block
+            for(let i=0;i<numBlocks;i++){ //Moving every block
                 if(blockDirection[curBlock]=='Right'){
                     blocks.children[i].x +=2;
                 }else{
@@ -508,7 +508,7 @@ var gameSquareOne = {
                 }
             }
             
-            var extra = 80-blockDistance[curBlock];
+            let extra = 80-blockDistance[curBlock];
             
             if(blockDirection[curBlock]=='Right'){
                 if(blocks.children[curBlock].x>=nextEnd+extra){
@@ -516,7 +516,7 @@ var gameSquareOne = {
                     blocks.y += 40;
                     curBlock +=1;
                     nextEnd += blockDistance[curBlock];
-                    for(var i=0; i<=floorIndex; i++ ){
+                    for(let i=0; i<=floorIndex; i++ ){
                         if(floorBlocks.children[i].x<(blocks.children[curBlock-1].x+blockDistance[curBlock-1])){
                             floorBlocks.children[i].alpha = 0.2;
                             curFloor = i;
@@ -529,7 +529,7 @@ var gameSquareOne = {
                     blocks.y += 40;
                     curBlock+=1;
                     nextEnd -= blockDistance[curBlock];
-                    for(var i=0; i<=floorIndex; i++ ){
+                    for(let i=0; i<=floorIndex; i++ ){
                         if(floorBlocks.children[i].x>(blocks.children[curBlock-1].x-blockDistance[curBlock-1])){
                             floorBlocks.children[i].alpha = 0.2;
                             curFloor = i;
@@ -549,14 +549,14 @@ var gameSquareOne = {
             tractor.animations.stop();
             timer.stop();
             //Check left blocks
-            var resultBlock = true;
-            for(var i=0; i<=blockIndex; i++){
+            let resultBlock = true;
+            for(let i=0; i<=blockIndex; i++){
                 if(blocks.children[i].alpha==1) resultBlock = false;
             }
             
             //check floor Holes
-            var resultFloor = true;
-            for(var i=0; i<=floorIndex; i++){
+            let resultFloor = true;
+            for(let i=0; i<=floorIndex; i++){
                 if(floorBlocks.children[i].alpha==1) resultFloor = false;
             }
                         
@@ -621,7 +621,7 @@ var gameSquareOne = {
         if(!clicked){
             //on level type A
             if(levelType=="A"){
-                for(var i=0;i<floorCount;i++){
+                for(let i=0;i<floorCount;i++){
                     if(i<=this.indice){
                         floorBlocks.children[i].alpha = 1;
                     }else{
@@ -631,7 +631,7 @@ var gameSquareOne = {
                 floorIndex = this.indice;
             //on level type B
             }else if(levelType=="B"){
-                for(var i=0;i<numBlocks;i++){
+                for(let i=0;i<numBlocks;i++){
                     if(i<=this.indice){
                         blocks.children[i].alpha = 0.5;
                     }else{
@@ -649,13 +649,13 @@ var gameSquareOne = {
         if(!clicked){
             //on level type A
             if(levelType=="A"){
-                for(var i=0;i<floorCount;i++){
+                for(let i=0;i<floorCount;i++){
                     floorBlocks.children[i].alpha = 0.5;
                 }
                 floorIndex = -1;
             //on level type B
             }else if(levelType=="B"){
-                for(var i=0;i<numBlocks;i++){
+                for(let i=0;i<numBlocks;i++){
                     blocks.children[i].alpha = 0.5;
                 }
                 blockIndex = -1;
@@ -686,13 +686,13 @@ var gameSquareOne = {
                 
                 //cleaning path
                 if(levelOperator=='Minus'){
-                    for(var i=0; i< floorCount; i++){
+                    for(let i=0; i< floorCount; i++){
                         if(i>floorIndex){
                             floorBlocks.children[i].alpha = 0;
                         }
                     }
                 }else{
-                    for(var i=0; i< floorCount; i++){
+                    for(let i=0; i< floorCount; i++){
                         if(i>floorIndex){
                             floorBlocks.children[i].alpha = 0;
                         }
@@ -704,8 +704,8 @@ var gameSquareOne = {
             //on level type B
             }else if(levelType=='B'){ //Delete unselected blocks
 
-                var minusBlocks = 0;
-                for(var i=0;i<numBlocks;i++){
+                let minusBlocks = 0;
+                for(let i=0;i<numBlocks;i++){
                     if(i<=blockIndex){
                         blocks.children[i].alpha = 1;
                     }else{
@@ -746,10 +746,10 @@ var gameSquareOne = {
         //DEBUG Testar 'lang'
         /*
         
-        var contact = "";
+        let contact = "";
         if (typeof lang === 'object') {
           //contact = JSON.parse(lang);
-          for (var i in lang) // will enumerate values of 'assets/languages/pt_BR.json'
+          for (let i in lang) // will enumerate values of 'assets/languages/pt_BR.json'
              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'
@@ -760,13 +760,13 @@ var gameSquareOne = {
     
         */
 
-        var abst = "numBlocks:" + numBlocks + ", valBlocks: " + detail + " blockIndex: " + blockIndex + ", floorIndex: " + floorIndex;
+        let abst = "numBlocks:" + numBlocks + ", valBlocks: " + detail + " blockIndex: " + blockIndex + ", floorIndex: " + floorIndex;
 
-        var hr = new XMLHttpRequest();
+        let hr = new XMLHttpRequest();
 
         // Create some variables we need to send to our PHP file
-        var url = "php/save.php";
-        var vars = "s_ip=" + hip + "&s_name=" + username + "&s_lang=" + lang + "&s_game=" + levelShape + "&s_mode=" + levelType;
+        let url = "php/save.php";
+        let 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;
 
@@ -788,7 +788,7 @@ var gameSquareOne = {
             if(debugMode) console.log(hr);
             
             if(hr.readyState == 4 && hr.status == 200) {
-                var return_data = hr.responseText;
+                let return_data = hr.responseText;
                 if(debugMode) console.log(return_data);
             }
         }
@@ -801,11 +801,11 @@ var gameSquareOne = {
     func_viewHelp: function(){
 
         if(!clicked){
-            var pointer;
+            let pointer;
             if(levelType=='A'){
-                var pointer = game.add.image(endPosition, 490, 'pointer');
+                let pointer = game.add.image(endPosition, 490, 'pointer');
             }else{
-                var pointer = game.add.image(blocks.children[endIndex-1].x, blocks.children[endIndex-1].y-blockSize/2, 'pointer');
+                let pointer = game.add.image(blocks.children[endIndex-1].x, blocks.children[endIndex-1].y-blockSize/2, 'pointer');
             }
             pointer.anchor.setTo(0.5, 0);
             pointer.alpha = 0.7;
@@ -817,7 +817,7 @@ var gameSquareOne = {
 
 /****************************** END ****************************/
 
-var endSquareOne = {
+let endSquareOne = {
 
     create: function() {  
 
@@ -830,18 +830,18 @@ var endSquareOne = {
         game.add.image(110, 85, 'cloud').scale.setTo(0.8);
         
         // Styles for labels
-        var stylePlace = { font: '26px Arial', fill: '#400080', align: 'center'};
-        var styleLabel = { font: '26px Arial', fill: '#000080', align: 'center'};
-        var styleMenu = { font: '30px Arial', fill: '#000000', align: 'center'};
+        let stylePlace = { font: '26px Arial', fill: '#400080', align: 'center'};
+        let styleLabel = { font: '26px Arial', fill: '#000080', align: 'center'};
+        let styleMenu = { font: '30px Arial', fill: '#000000', align: 'center'};
         
         //Floor
-        for(var i=0;i<9;i++){
+        for(let i=0;i<9;i++){
             game.add.image(i*100, 501, 'floor');
         }
         
         // Progress bar
-        for(var p=0;p<5;p++){
-            var block = game.add.image(660+p*30, 10, 'block');
+        for(let p=0;p<5;p++){
+            let block = game.add.image(660+p*30, 10, 'block');
             block.scale.setTo(2, 1); //Scaling to double width
         }
         game.add.text(820, 10, '100%', styleMenu);

+ 87 - 87
js/squareTwo.js

@@ -1,12 +1,12 @@
 /*
 
-    var menuSquareTwo = {
+    let menuSquareTwo = {
         create: function(){},
         ---------------------------- end of phaser functions
         func_loadMap: function(){}
     };
 
-    var gameSquareTwo = {
+    let gameSquareTwo = {
         create: function(){},
         update: function(){},
         ---------------------------- end of phaser functions
@@ -22,7 +22,7 @@
             
     };
 
-    var endSquareTwo = {
+    let endSquareTwo = {
         create: function(){},
         update: function(){},
         ---------------------------- end of phaser functions
@@ -35,7 +35,7 @@
 
 /****************************** MENU ****************************/
 
-var menuSquareTwo = {
+let menuSquareTwo = {
 
     create: function() {
           
@@ -46,34 +46,34 @@ var menuSquareTwo = {
                                     false,false);
         
         // Setting title
-        var style = { font: '28px Arial', fill: '#00804d'};
-        var title = game.add.text(game.world.centerX, 40, lang.game_menu_title, style);
+        let style = { font: '28px Arial', fill: '#00804d'};
+        let title = game.add.text(game.world.centerX, 40, lang.game_menu_title, style);
         title.anchor.setTo(0.5, 0.5);
         
         //SETTING DIFFICULTY LEVELS
 
-        var maxHeight = 120;  //Max height of a stair
-        var stairHeight = 29; //height growth of a stair
-        var stairWidth = 80;  //Width of a stair
-        var startStair = 240;
-        var startSymbol = 150;
-        var startSquare = (startSymbol/2)+startStair+stairWidth*5;
+        let maxHeight = 120;  //Max height of a stair
+        let stairHeight = 29; //height growth of a stair
+        let stairWidth = 80;  //Width of a stair
+        let startStair = 240;
+        let startSymbol = 150;
+        let startSquare = (startSymbol/2)+startStair+stairWidth*5;
         
-        var equalsIcon = game.add.sprite(startSymbol, 300, 'equal');
+        let equalsIcon = game.add.sprite(startSymbol, 300, 'equal');
             equalsIcon.frame = 0;
             equalsIcon.scale.setTo(0.7);
             equalsIcon.anchor.setTo(0.5,0.5);
             
         //First stairs, More divisions to less divisions 1, 5 levels
 
-        var stairsMoreToLess1 = [];
+        let stairsMoreToLess1 = [];
 
-        for(var i=1;i<=5;i++){
+        for(let i=1;i<=5;i++){
             //stair
-            var x1 = startStair+(stairWidth*(i-1));
-            var y1 = 100+maxHeight-i*stairHeight;
-            var x2 = stairWidth;//x1 + 40;
-            var y2 = stairHeight*i;//y1 + 24;
+            let x1 = startStair+(stairWidth*(i-1));
+            let y1 = 100+maxHeight-i*stairHeight;
+            let x2 = stairWidth;//x1 + 40;
+            let y2 = stairHeight*i;//y1 + 24;
             
             stairsMoreToLess1[i] = game.add.graphics(0, 0);
             stairsMoreToLess1[i].lineStyle(1, 0xFFFFFF, 1);
@@ -89,22 +89,22 @@ var menuSquareTwo = {
             stairsMoreToLess1[i].events.onInputOut.add(function (item) { item.alpha=1; }, this);
             
             //label
-            var xl = x1+stairWidth/2; //x label
-            var yl = y1+(stairHeight*i)/2; //y label
-            var label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' });
+            let xl = x1+stairWidth/2; //x label
+            let yl = y1+(stairHeight*i)/2; //y label
+            let label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' });
                 label.anchor.setTo(0.5, 0.4);
         }
 
         //Second stairs, More divisions to less divisions 2, 5 levels
 
-        var stairsMoreToLess2 = [];
+        let stairsMoreToLess2 = [];
 
-        for(var i=1;i<=5;i++){
+        for(let i=1;i<=5;i++){
             //stair
-            var x1 = startStair+(stairWidth*(i-1));
-            var y1 = 270+maxHeight-i*stairHeight;
-            var x2 = stairWidth;//x1 + 40;
-            var y2 = stairHeight*i;//y1 + 24;
+            let x1 = startStair+(stairWidth*(i-1));
+            let y1 = 270+maxHeight-i*stairHeight;
+            let x2 = stairWidth;//x1 + 40;
+            let y2 = stairHeight*i;//y1 + 24;
             
             stairsMoreToLess2[i] = game.add.graphics(0, 0);
             stairsMoreToLess2[i].lineStyle(1, 0xFFFFFF, 1);
@@ -120,22 +120,22 @@ var menuSquareTwo = {
             stairsMoreToLess2[i].events.onInputOut.add(function (item) { item.alpha=1; }, this);
             
             //label
-            var xl = x1+stairWidth/2; //x label
-            var yl = y1+(stairHeight*i)/2; //y label
-            var label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' });
+            let xl = x1+stairWidth/2; //x label
+            let yl = y1+(stairHeight*i)/2; //y label
+            let label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' });
                 label.anchor.setTo(0.5, 0.4);
         } 
         
         //Third stairs, Less divisions to more divisions, 5 levels
 
-        var stairsLessToMore = [];
+        let stairsLessToMore = [];
 
-        for(var i=1;i<=5;i++){
+        for(let i=1;i<=5;i++){
             //stair
-            var x1 = startStair+(stairWidth*(i-1));
-            var y1 = 440+maxHeight-i*stairHeight;
-            var x2 = stairWidth;//x1 + 40;
-            var y2 = stairHeight*i;//y1 + 24;
+            let x1 = startStair+(stairWidth*(i-1));
+            let y1 = 440+maxHeight-i*stairHeight;
+            let x2 = stairWidth;//x1 + 40;
+            let y2 = stairHeight*i;//y1 + 24;
             
             stairsLessToMore[i] = game.add.graphics(0, 0);
             stairsLessToMore[i].lineStyle(1, 0xFFFFFF, 1);
@@ -151,9 +151,9 @@ var menuSquareTwo = {
             stairsLessToMore[i].events.onInputOut.add(function (item) { item.alpha=1; }, this);
             
             //label
-            var xl = x1+stairWidth/2; //x label
-            var yl = y1+(stairHeight*i)/2; //y label
-            var label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' });
+            let xl = x1+stairWidth/2; //x label
+            let yl = y1+(stairHeight*i)/2; //y label
+            let label = game.add.text(xl, yl, i, { font: '25px Arial', fill: '#ffffff', align: 'center' });
                 label.anchor.setTo(0.5, 0.4);
         } 
 
@@ -180,7 +180,7 @@ var menuSquareTwo = {
 
 /****************************** GAME ****************************/
 
-var gameSquareTwo = {
+let gameSquareTwo = {
 
     create: function() {  
         
@@ -207,13 +207,13 @@ var gameSquareTwo = {
         game.add.image(110, 85, 'cloud').scale.setTo(0.8);
         
         // Styles for labels
-        var stylePlace = { font: '26px Arial', fill: '#400080', align: 'center'};
-        var styleLabel = { font: '26px Arial', fill: '#000080', align: 'center'};
-        var styleFraction = { font: '20px Arial', fill: '#000080', align: 'center'};
-        var styleMenu = { font: '30px Arial', fill: '#000000', align: 'center'};
+        let stylePlace = { font: '26px Arial', fill: '#400080', align: 'center'};
+        let styleLabel = { font: '26px Arial', fill: '#000080', align: 'center'};
+        let styleFraction = { font: '20px Arial', fill: '#000080', align: 'center'};
+        let styleMenu = { font: '30px Arial', fill: '#000000', align: 'center'};
         
         //Floor
-        for(var i=0;i<9;i++){
+        for(let i=0;i<9;i++){
             game.add.image(i*100, 501, 'floor');
         }
              
@@ -246,7 +246,7 @@ var gameSquareTwo = {
         if(debugMode) console.log("----------");
         if(debugMode) console.log("Diff " + levelDifficulty + ", ini " + ((levelDifficulty-1)*2+1) + ", end " + ((levelDifficulty-1)*2+3));
         
-        var rPoint = game.rnd.integerInRange((levelDifficulty-1)*2+1,(levelDifficulty-1)*2+3);
+        let rPoint = game.rnd.integerInRange((levelDifficulty-1)*2+1,(levelDifficulty-1)*2+3);
         sizeA = points[rPoint];
         
         if(debugMode) console.log("Rpoint " + rPoint + ", val " + sizeA);
@@ -275,15 +275,15 @@ var gameSquareTwo = {
         }
              
         //Blocks A
-        var widthA = blockW/sizeA;
-        var lineColor = 0x1e2f2f;
-        var fillColor = 0x83afaf;
-        var fillColorS = 0xe0ebeb;
+        let widthA = blockW/sizeA;
+        let lineColor = 0x1e2f2f;
+        let fillColor = 0x83afaf;
+        let fillColorS = 0xe0ebeb;
         
-        for(var i=0; i<sizeA; i++){
+        for(let i=0; i<sizeA; i++){
             //if(debugMode) console.log("Block A"+i+": x:"+(xA+i*widthA)+", y:"+yA);
                         
-            var block = game.add.graphics(xA+i*widthA, yA);
+            let block = game.add.graphics(xA+i*widthA, yA);
                 block.anchor.setTo(0.5, 0.5);
                 block.lineStyle(2, lineColor);
                 block.beginFill(fillColor);
@@ -300,9 +300,9 @@ var gameSquareTwo = {
             blocksA.add(block);
             
             //aux blocks
-            var xAux = xA+i*widthA, yAux = yA+blockH+10;
+            let xAux = xA+i*widthA, yAux = yA+blockH+10;
             if(levelOperator == 'C') yAux = yA;
-            var block = game.add.graphics(xAux, yAux );
+                block = game.add.graphics(xAux, yAux );
                 block.anchor.setTo(0.5, 0.5);
                 block.lineStyle(1, lineColor);
                 block.beginFill(fillColorS);
@@ -316,8 +316,8 @@ var gameSquareTwo = {
         }
         
         //label block A
-        var labelX = xA+blockW+30;
-        var labelY = yA+blockH/2;
+        let labelX = xA+blockW+30;
+        let labelY = yA+blockH/2;
         labelA = game.add.text(labelX, labelY, sizeA , styleFraction);
         labelA.anchor.setTo(0.5, 0.41);
         
@@ -333,14 +333,14 @@ var gameSquareTwo = {
         separatorA.alpha = 0;
         
         //Blocks B
-        var widthB = blockW/sizeB;
+        let widthB = blockW/sizeB;
         lineColor = 0x260d0d;
         fillColor = 0xd27979;
         fillColorS = 0xf2d9d9;
                
-        for(var i=0; i<sizeB; i++){
+        for(let i=0; i<sizeB; i++){
                         
-            var block = game.add.graphics(xB+i*widthB, yB);
+            let block = game.add.graphics(xB+i*widthB, yB);
                 block.anchor.setTo(0.5, 0.5);
                 block.lineStyle(2, lineColor);
                 block.beginFill(fillColor);
@@ -355,9 +355,9 @@ var gameSquareTwo = {
 
             blocksB.add(block);
             //aux blocks
-            var xAux = xB+i*widthB, yAux = yB+blockH+10;
+            let xAux = xB+i*widthB, yAux = yB+blockH+10;
             if(levelOperator == 'C') yAux = yB;
-            var block = game.add.graphics(xAux, yAux);
+                block = game.add.graphics(xAux, yAux);
                 block.anchor.setTo(0.5, 0.5);
                 block.lineStyle(1, lineColor);
                 block.beginFill(fillColorS);
@@ -410,7 +410,7 @@ var gameSquareTwo = {
     update: function() {
     	if (game.physics.arcade.distanceToPointer(kid, game.input.activePointer) > 20 ){	
     		    		
-        	var xPos = game.input.mousePointer.x;
+        	let xPos = game.input.mousePointer.x;
         	
         	/*if (xPos < kid.x + 10){
         		kidDirection='right';
@@ -433,7 +433,7 @@ var gameSquareTwo = {
     	
         //If clicked A only, animate
         if(animateA){
-            for(var i=0;i<valueA;i++){
+            for(let i=0;i<valueA;i++){
                 blocksA.children[i].y +=2;
             }
             if(blocksA.children[0].y>=auxblqA.children[0].y){
@@ -446,7 +446,7 @@ var gameSquareTwo = {
 
         //If clicked B only, animate
         if(animateB){ 
-            for(var i=0;i<valueB;i++){
+            for(let i=0;i<valueB;i++){
                 blocksB.children[i].y +=2;
             }
             if(blocksB.children[0].y>=auxblqB.children[0].y){
@@ -524,7 +524,7 @@ var gameSquareTwo = {
             }else{    
                 errorTextA.setText("");
                 errorTextB.setText("");
-                for(var i=0;i<sizeA;i++){
+                for(let i=0;i<sizeA;i++){
                     if(i<=this.indice){
                         blocksA.children[i].alpha = 1;
                     }else{
@@ -549,7 +549,7 @@ var gameSquareTwo = {
             }else{
                 errorTextA.setText("");
                 errorTextB.setText("");
-                for(var i=0;i<sizeB;i++){
+                for(let i=0;i<sizeB;i++){
                     if(i<=this.indice){
                         blocksB.children[i].alpha = 1;
                     }else{
@@ -567,13 +567,13 @@ var gameSquareTwo = {
     func_outSquare: function(){
 
         if(!clickA && this.who=="A"){
-            for(var i=0;i<=this.indice;i++){
+            for(let i=0;i<=this.indice;i++){
                 blocksA.children[i].alpha = 0.5;
             }
             fractionA.alpha = 0;
         }
         if(!clickB && this.who=="B"){
-            for(var i=0;i<=this.indice;i++){
+            for(let i=0;i<=this.indice;i++){
                 blocksB.children[i].alpha = 0.5;
             }
             fractionB.alpha = 0;
@@ -584,7 +584,7 @@ var gameSquareTwo = {
     func_clickSquare: function(){
 
         if(!clickA && this.who=="A" && this.indice!=sizeA-1){
-            for(var i=0;i<sizeA;i++){
+            for(let i=0;i<sizeA;i++){
                 blocksA.children[i].inputEnabled = false;
                 if(i<=this.indice){
                     blocksA.children[i].alpha = 1;
@@ -605,7 +605,7 @@ var gameSquareTwo = {
         }
 
         if(!clickB && this.who=="B" && this.indice!=sizeB-1){
-            for(var i=0;i<sizeB;i++){
+            for(let i=0;i<sizeB;i++){
                 blocksB.children[i].inputEnabled = false;
                 if(i<=this.indice){
                     blocksB.children[i].alpha = 1;
@@ -629,12 +629,12 @@ var gameSquareTwo = {
     
     func_postScore: function (){
     
-        var abst = "numBlocksA:" + sizeA + ", valueA: " + valueA +", numBlocksB: " + sizeB + ", valueB: " + valueB;
+        let abst = "numBlocksA:" + sizeA + ", valueA: " + valueA +", numBlocksB: " + sizeB + ", valueB: " + valueB;
         
-        var hr = new XMLHttpRequest();
+        let hr = new XMLHttpRequest();
         // Create some variables we need to send to our PHP file
-        var url = "php/save.php";
-        var vars = "s_ip="+hip+"&s_name=" + username + "&s_lang=" + lang + "&s_game=" + levelShape + "&s_mode=" + levelType;
+        let url = "php/save.php";
+        let vars = "s_ip="+hip+"&s_name=" + username + "&s_lang=" + lang + "&s_game=" + levelShape + "&s_mode=" + levelType;
 
         vars += "&s_oper=Equal&s_leve=" + levelDifficulty + "&s_posi=" + levelPosition + "&s_resu=" + result + "&s_time=" + totalTime + "&s_deta=" + abst;
         
@@ -644,7 +644,7 @@ var gameSquareTwo = {
             if(debugMode) console.log(hr);
 
             if(hr.readyState == 4 && hr.status == 200) {
-                var return_data = hr.responseText;
+                let return_data = hr.responseText;
                 if(debugMode) console.log(return_data);
             }
         }
@@ -657,15 +657,15 @@ var gameSquareTwo = {
     //Calculation help functions
     func_getRndDivisor: function(number){ //Get random divisor for a number
 
-        var div = []; //Divisors found
-        var p = 0; //current dividor index
-        for(var i=2; i<number;i++){
+        let div = []; //Divisors found
+        let p = 0; //current dividor index
+        for(let i=2; i<number;i++){
             if(number%i==0){
                 div[p] = i;
                 p++;
             }
         }
-        var x = game.rnd.integerInRange(0,p-1);
+        let x = game.rnd.integerInRange(0,p-1);
         return div[x];
 
     },
@@ -674,7 +674,7 @@ var gameSquareTwo = {
 
 /****************************** END ****************************/
 
-var endSquareTwo = {
+let endSquareTwo = {
 
     create: function() {  
 
@@ -687,18 +687,18 @@ var endSquareTwo = {
         game.add.image(110, 85, 'cloud').scale.setTo(0.8);
         
         // Styles for labels
-        var stylePlace = { font: '26px Arial', fill: '#400080', align: 'center'};
-        var styleLabel = { font: '26px Arial', fill: '#000080', align: 'center'};
-        var styleMenu = { font: '30px Arial', fill: '#000000', align: 'center'};
+        let stylePlace = { font: '26px Arial', fill: '#400080', align: 'center'};
+        let styleLabel = { font: '26px Arial', fill: '#000080', align: 'center'};
+        let styleMenu = { font: '30px Arial', fill: '#000000', align: 'center'};
         
         //Floor
-        for(var i=0;i<9;i++){
+        for(let i=0;i<9;i++){
             game.add.image(i*100, 501, 'floor');
         }
         
         // Progress bar
-        for(var p=1;p<=5;p++){
-            var block = game.add.image(660+(p-1)*30, 10, 'block');
+        for(let p=1;p<=5;p++){
+            let block = game.add.image(660+(p-1)*30, 10, 'block');
             block.scale.setTo(2, 1); //Scaling to double width
         }
         game.add.text(820, 10, '100%', styleMenu);