Przeglądaj źródła

added ON/OFF sound button | fixed bug on the last difficulty of the last phase where feedback message would appear in wrong place | rearranged code and button locations on screen

lairaalmas 5 lat temu
rodzic
commit
bd1647623c

BIN
assets/img/menu/audio_48x48.png


+ 2 - 1
assets/languages/en_US.json

@@ -21,5 +21,6 @@
     "ready" : "READY",
     "welcome" : "Welcome",
     "error_msg" :  "You should select a smaller portion than it's full size",
-    "empty_name" : "You forgot to type your name"
+    "empty_name" : "You forgot to type your name",
+    "audio" : "AUDIO"
 }

+ 2 - 1
assets/languages/es_PE.json

@@ -21,5 +21,6 @@
     "ready" : "LISTO",
     "welcome" : "Bienvenid@",
     "error_msg" : "Debes seleccionar una porción más pequeña que su tamaño completo",
-    "empty_name" : "Usted ha olvidado de escribir su nombre"
+    "empty_name" : "Usted ha olvidado de escribir su nombre",
+    "audio" : "AUDIO"
 }

+ 2 - 1
assets/languages/fr_FR.json

@@ -21,5 +21,6 @@
     "ready" : "PRET",
     "welcome" : "Bienvenue",
     "error_msg" : "Vous devriez choisir une portion plus petite que sa taille totale",
-    "empty_name" : "Vous avez oublié de taper votre nom"
+    "empty_name" : "Vous avez oublié de taper votre nom",
+    "audio" : "AUDIO"
 }

+ 2 - 1
assets/languages/pt_BR.json

@@ -21,5 +21,6 @@
     "ready" : "PRONTO",
     "welcome" : "Bem vind@",
     "error_msg" : "Você deve selecionar uma porção menor que o seu tamanho total",
-    "empty_name" : "Você esqueceu de digitar seu nome"
+    "empty_name" : "Você esqueceu de digitar seu nome",
+    "audio" : "ÁUDIO" 
 }

+ 3 - 2
index.html

@@ -10,12 +10,12 @@
         
         <script src="js/phaser.min.js"></script>
         
-        <script type="text/javascript" src="js/boot.js"></script>
+        <script type="text/javascript" src="js/preMenu.js"></script>
         <script type="text/javascript" src="js/menu.js"></script>
         <script type="text/javascript" src="js/circleOne.js"></script>
         <script type="text/javascript" src="js/squareOne.js"></script>
         <script type="text/javascript" src="js/squareTwo.js"></script>
-        <script type="text/javascript" src="js/auxiliar.js"></script>
+        <script type="text/javascript" src="js/boot.js"></script>
 
         <style>
         	#text-field-div{
@@ -46,6 +46,7 @@
 	    	<div class="clearfix"></div>
 	        
 	        <div class="panel panel-primary">
+	        <!--  <div class="panel-heading">iFractions :: Interactive Fractions Game</div> -->
 	          <div class="panel-heading">IFRACTIONS GAME</div>
 	          <div class="panel-body">
 	            <center>

+ 0 - 61
js/auxiliar.js

@@ -1,61 +0,0 @@
-
-    var timer, totalTime;
-
-    // Initialize the game
-    var game = new Phaser.Game(
-        900, 
-        600, 
-        Phaser.CANVAS,
-        'fractions-game'
-    );
-
-    hip = "143.107.45.11"; //Host ip
-    name = ""; //player name
-    lang = ""; //language
-
-    // Game One : kid and truck
-
-    onePosition = 0; //Map position
-    oneMove = false; //Move to next position
-    oneDifficulty = 0; //From one to five 
-    oneOperator= ""; //Plus; Minus; Mixed
-    oneLabel= false; //Show block label
-    oneShape = ""; //Circle; square
-    oneType = ""; // A - Place distance; B - Select blocks
-    oneMenu = true;
-
-    // Game Two : fractions association
-
-    twoPosition = 0; //Map position
-    twoMove = false; //Move to next position
-    twoDifficulty = 0; //From one to five 
-    twoOperator= ""; //Plus; Minus; Mixed
-    twoLabel= false; //Show block label
-    twoShape = ""; //Circle; square
-    twoType = ""; // A - Normal position; B - Random position
-    twoMenu= true;
-
-    //adding game states (scenes)
-    game.state.add('boot', bootState); // boot.js
-    game.state.add('load', loadState); // boot.js
-    game.state.add('name', nameState); // boot.js
-
-    game.state.add('menu', menuState); // menu.js
-
-    game.state.add('menuCOne', menuCircleOne); // circleOne.js
-    game.state.add('mapCOne', mapCircleOne); // circleOne.js
-    game.state.add('gameCOne', gameCircleOne); // circleOne.js
-    game.state.add('endCOne', endCircleOne); // circleOne.js
-
-    game.state.add('menuSOne', menuSquareOne); // squareOne.js
-    game.state.add('mapSOne', mapSquareOne); // squareOne.js
-    game.state.add('gameSOne', gameSquareOne); // squareOne.js
-    game.state.add('endSOne', endSquareOne); // squareOne.js
-
-    game.state.add('menuSTwo', menuSquareTwo); // squareTwo.js
-    game.state.add('mapSTwo', mapSquareTwo); // squareTwo.js
-    game.state.add('gameSTwo', gameSquareTwo); // squareTwo.js
-    game.state.add('endSTwo', endSquareTwo); // squareTwo.js
-
-    //starting to boot game
-    game.state.start('boot');

+ 162 - 294
js/boot.js

@@ -1,294 +1,162 @@
-var username, errorEmptyName, words;
-
-/*
-    var bootState = {
-        preload: function(){},
-        create: function(){},
-        --------------------------------------- end of phaser functions
-        setLang: function(){} //calls loadState
-    };
-    
-    var loadState = {
-        preload: function(){},
-        create: function(){} //calls nameState
-        -------------------------------------- end of phaser functions
-    };
-        
-    var nameState = {
-        preload: function(){},
-        create: function(){},
-        ------------------------------------------------ end of phaser functions
-        ready: function(){} //calls menu.js -> menuState
-    };
-*/
-
-// choose language screen
-var bootState = {
-
-    //Loading all assets   
-    preload: function() {
-        
-        var imgsrc = 'assets/img/';
-
-        //Progress bar image
-        game.load.image('progressBar', imgsrc+'pgbar.png');
-
-        //flags
-        game.load.image('flag_BR', imgsrc+'flag/BRAZ.jpg');
-        game.load.image('flag_PE', imgsrc+'flag/PERU.jpg');
-        game.load.image('flag_US', imgsrc+'flag/UNST.jpg');
-        game.load.image('flag_FR', imgsrc+'flag/FRAN.jpg');
-
-        //scenario
-        game.load.image('bgimage', imgsrc+'bg.jpg');
-        game.load.image('bgmap', imgsrc+'bg_map.png');
-        game.load.image('cloud', imgsrc+'cloud.png');
-        game.load.image('floor', imgsrc+'floor.png');
-        game.load.image('road', imgsrc+'road.png');
-        
-        //game phases buttons list
-        game.load.image('game1c', imgsrc+'game/one-c.png');
-        game.load.image('game2c', imgsrc+'game/two-c.png');
-        game.load.image('game3c', imgsrc+'game/three-c.png');
-        game.load.image('game4c', imgsrc+'game/four-c.png');
-        game.load.image('game1s', imgsrc+'game/one-s.png');
-        game.load.image('game2s', imgsrc+'game/two-s.png');
-        game.load.image('game3s', imgsrc+'game/three-s.png');
-        game.load.image('game4s', imgsrc+'game/four-s.png');
-        game.load.image('game5s', imgsrc+'game/five-s.png');
-        
-        //header menu buttons
-        game.load.image('back', imgsrc+'menu/back.png');
-        game.load.image('home', imgsrc+'menu/home.png');
-        game.load.image('info', imgsrc+'menu/info.png');
-        game.load.image('world', imgsrc+'menu/language.png');
-        game.load.image('list', imgsrc+'menu/menu.png');
-        game.load.image('help', imgsrc+'menu/help.png');
-        game.load.image('pgbar', imgsrc+'menu/progressBar.png');
-        game.load.image('block', imgsrc+'menu/block.png');
-        game.load.image('eraser', imgsrc+'menu/eraser.png');
-        
-        //operators
-        game.load.image('add', imgsrc+'operator/add.png');
-        game.load.image('subtract', imgsrc+'operator/subtract.png');
-        game.load.image('separator', imgsrc+'operator/separator.png');
-        game.load.image('equal', imgsrc+'operator/equal.png');
-        
-        //feedback
-        game.load.image('h_arrow', imgsrc+'help/arrow.png');
-        game.load.image('h_double', imgsrc+'help/double.png');
-        game.load.image('h_error', imgsrc+'help/error.png');
-        game.load.image('h_ok', imgsrc+'help/ok.png');
-        game.load.image('down', imgsrc+'help/down.png');        
-        game.load.image('pointer', imgsrc+'help/pointer.png');
-        
-        // Loading assets based on language        
-        game.load.spritesheet('kid_run', imgsrc+'kid/run.png', 82, 178, 12);
-        game.load.spritesheet('kid_walk', imgsrc+'kid/walk.png', 78, 175, 24);
-        game.load.spritesheet('kid_lost', imgsrc+'kid/lost.png', 72, 170, 6);
-        game.load.spritesheet('tractor', imgsrc+'tractor/frame.png', 201, 144, 10);
-        game.load.image('balloon', imgsrc+'airballoon_upper.png');
-        game.load.image('balloon_basket', imgsrc+'airballoon_base.png');
-        game.load.image('birch', imgsrc+'birch.png');
-        game.load.image('flag', imgsrc+'flag.png');
-        game.load.image('house', imgsrc+'house.png');
-        game.load.image('place_a', imgsrc+'place_a.png');
-        game.load.image('place_b', imgsrc+'place_b.png');
-        game.load.image('garage', imgsrc+'garage.png');
-        game.load.image('farm', imgsrc+'farm.png');
-        game.load.image('rock', imgsrc+'rock.png');
-        game.load.image('school', imgsrc+'school.png');
-        game.load.image('sign', imgsrc+'sign.png');
-        game.load.image('tree1', imgsrc+'tree.png');
-        game.load.image('tree2', imgsrc+'tree2.png');
-        game.load.image('tree3', imgsrc+'tree3.png');
-        game.load.image('tree4', imgsrc+'tree4.png');
-        
-        // Loadind Sound Effects
-        game.load.audio('sound_ok', ['assets/fx/ok.ogg', 'assets/fx/ok.mp3']);
-        game.load.audio('sound_error', ['assets/fx/error.ogg', 'assets/fx/error.mp3']);
-        game.load.audio('sound_beep', ['assets/fx/beep.ogg', 'assets/fx/beep.mp3']);
-    },
-
-    create: function() {
-
-        //game settings
-        game.stage.backgroundColor = '#cce5ff';
-        game.physics.startSystem(Phaser.Physics.ARCADE);
-        var style = { font: '28px Arial', fill: '#00804d', align: 'center' };
-
-        //generating language selection
-
-        //pt_BR
-        var title1 = game.add.text(this.game.world.centerX - 220, this.game.world.centerY - 100, 'FRAÇÕES  ', style);
-        title1.anchor.setTo(1, 0.5);
-        var flag1 = game.add.sprite(this.game.world.centerX - 220, this.game.world.centerY - 100, 'flag_BR');       
-        flag1.anchor.setTo(0, 0.5);
-        flag1.inputEnabled = true;
-        flag1.input.useHandCursor = true;
-        flag1.events.onInputDown.add(this.setLang,{lang:'pt_BR'});
-
-        //es_PE
-        var title2 = game.add.text(this.game.world.centerX + 200, this.game.world.centerY - 100, 'FRACCIONES  ', style);
-        title2.anchor.setTo(1, 0.5);
-        var flag2 = game.add.sprite(this.game.world.centerX + 200, this.game.world.centerY - 100, 'flag_PE');       
-        flag2.anchor.setTo(0, 0.5);
-        flag2.inputEnabled = true;
-        flag2.input.useHandCursor = true;
-        flag2.events.onInputDown.add(this.setLang,{lang:'es_PE'});
-
-        //en_US
-        var title3 = game.add.text(this.game.world.centerX - 220, this.game.world.centerY + 100, 'FRACTIONS  ', style);
-        title3.anchor.setTo(1, 0.5);
-        var flag3 = game.add.sprite(this.game.world.centerX - 220, this.game.world.centerY + 100, 'flag_US');       
-        flag3.anchor.setTo(0, 0.5);
-        flag3.inputEnabled = true;
-        flag3.input.useHandCursor = true;
-        flag3.events.onInputDown.add(this.setLang,{lang:'en_US'});
-
-        //fr_FR
-        var title4 = game.add.text(this.game.world.centerX + 200, this.game.world.centerY + 100, 'FRACTIONS  ', style);
-        title4.anchor.setTo(1, 0.5);
-        var flag4 = game.add.sprite(this.game.world.centerX + 200, this.game.world.centerY + 100, 'flag_FR');       
-        flag4.anchor.setTo(0, 0.5);
-        flag4.inputEnabled = true;
-        flag4.input.useHandCursor = true;
-        flag4.events.onInputDown.add(this.setLang,{lang:'fr_FR'});
-        
-    },
-    
-    setLang: function(){
-        //set language
-        lang = this.lang;
-        //start resource loading
-        game.state.start('load');
-    }
-
-};
-
-// loading screen (+loading assets)
-var loadState = {
-    
-    preload: function() {
-        
-        // Displaying the progress bar
-        var progressBar = game.add.sprite(game.world.centerX, game.world.centerY, 'progressBar');
-        progressBar.anchor.setTo(0.5, 0.5);
-        game.load.setPreloadSprite(progressBar);
-        
-        if(!oneMenu){
-            game.stage.backgroundColor = '#cce5ff';
-            game.physics.startSystem(Phaser.Physics.ARCADE);
-        }
-        
-        // Loading dictionary
-        game.load.json('dictionary', 'assets/languages/'+lang+'.json');
-        
-    },
-
-    create: function() {  
-        game.state.start('name');
-    }
-};
-
-// type name screen
-var nameState = {
-
-    preload: function () {
-        
-    },
-
-    create: function() {
-        game.stage.backgroundColor = '#cce5ff';
-        
-        // gets selected language from json
-        words = game.cache.getJSON('dictionary');
-        
-        game.physics.startSystem(Phaser.Physics.ARCADE);
-        
-        var style = { font: '30px Arial', fill: '#00804d', align: 'center' };
-        var styleName = { font: '44px Arial', fill: '#000000', align: 'center' };
-        
-        // title
-        var title = game.add.text(this.game.world.centerX, this.game.world.centerY - 100, words.insert_name, style);
-        title.anchor.setTo(0.5);
-        
-        // "READY" button
-        var 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);
-        btn.alpha = 0.5;
-        btn.endFill();
-        
-        btn.inputEnabled = true;
-        btn.input.useHandCursor = true;
-        btn.events.onInputDown.add(this.nameIsEmpty, null);
-        
-        var ready = game.add.text(this.game.world.centerX + 1, this.game.world.centerY + 102, words.ready, { font: '34px Arial', fill: '#f0f5f5', align: 'center' });
-        ready.anchor.setTo(0.5);
-
-        errorEmptyName = game.add.text(this.game.world.centerX, this.game.world.centerY - 70, "", {font: '18px Arial', fill: '#330000', align: 'center'});
-        errorEmptyName.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; 
-            //se apertar enter vai para ready, assim como o botão
-            if(keycode == 13){
-                nameState["nameIsEmpty"]();
-            }     
-        });
-    },
-         
-    nameIsEmpty: function() {
-        if(document.getElementById("name_id").value!=""){
-            nameState["ready"]();
-            errorEmptyName.setText("");
-        }else{
-            errorEmptyName.setText(words.empty_name);
-        }
-
-    },
-
-    //var ready = function readyFunction() {...},
-    //var ready = function() {...},                
-    ready: function() {
-        
-        // saves the typed name on username variable
-        username = document.getElementById("name_id").value;
-        console.log("user is" + username);        
-
-        document.getElementById("text-field-div").style.visibility = "hidden";
-
-        //clears the text field again
-        document.getElementById("name_id").value = "";
-
-        if(oneMenu){ //If menu, normal game
-            // Go to the menu state
-            game.state.start('menu');
-        }else{ //parameters game
-            if(oneShape=="Circle"){
-                game.state.start("mapCOne");
-            }else if(oneShape=="Square"){
-                if(oneOperator=='Mixed'){
-                    twoPosition = 0;
-                    twoMove = true;
-                    twoDifficulty = oneDifficulty; 
-                    twoOperator= "";
-                    twoLabel= false;
-                    twoShape = oneShape;
-                    twoType = oneType;
-                    twoMenu = false;
-                    
-                    game.state.start("mapSTwo");
-                }else{
-                    game.state.start("mapSOne");
-                }
-            }
-            
-        }
-        
-    }
-
-};
+
+	var username; //user info
+	var lang; //language
+
+	var beepSound, okSound, errorSound; //sounds
+	var okImg, errorImg;
+
+    var timer, totalTime;
+
+    var audioStatus = true;
+
+    // Initialize the game
+    var game = new Phaser.Game(
+        900, 
+        600, 
+        Phaser.CANVAS,
+        'fractions-game'
+    );
+
+    hip = "143.107.45.11"; //Host ip
+    name = ""; //player name
+    lang = ""; //language
+
+    // Game One : kid and truck
+
+    onePosition = 0; //Map position
+    oneMove = false; //Move to next position
+    oneDifficulty = 0; //From one to five 
+    oneOperator= ""; //Plus; Minus; Mixed
+    oneLabel= false; //Show block label
+    oneShape = ""; //Circle; square
+    oneType = ""; // A - Place distance; B - Select blocks
+    oneMenu = true;
+
+    // Game Two : fractions association
+
+    twoPosition = 0; //Map position
+    twoMove = false; //Move to next position
+    twoDifficulty = 0; //From one to five 
+    twoOperator= ""; //Plus; Minus; Mixed
+    twoLabel= false; //Show block label
+    twoShape = ""; //Circle; square
+    twoType = ""; // A - Normal position; B - Random position
+    twoMenu= 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('menu', menuState); // menu.js
+
+    game.state.add('menuCOne', menuCircleOne); // circleOne.js
+    game.state.add('mapCOne', mapCircleOne); // circleOne.js
+    game.state.add('gameCOne', gameCircleOne); // circleOne.js
+    game.state.add('endCOne', endCircleOne); // circleOne.js
+
+    game.state.add('menuSOne', menuSquareOne); // squareOne.js
+    game.state.add('mapSOne', mapSquareOne); // squareOne.js
+    game.state.add('gameSOne', gameSquareOne); // squareOne.js
+    game.state.add('endSOne', endSquareOne); // squareOne.js
+
+    game.state.add('menuSTwo', menuSquareTwo); // squareTwo.js
+    game.state.add('mapSTwo', mapSquareTwo); // squareTwo.js
+    game.state.add('gameSTwo', gameSquareTwo); // squareTwo.js
+    game.state.add('endSTwo', endSquareTwo); // squareTwo.js
+
+    var loadAssets = {
+
+    	preload: function(){
+    
+	        var imgsrc = 'assets/img/';
+
+	        //Progress bar image
+	        game.load.image('progressBar', imgsrc+'pgbar.png');
+
+	        //flags
+	        game.load.image('flag_BR', imgsrc+'flag/BRAZ.jpg');
+	        game.load.image('flag_PE', imgsrc+'flag/PERU.jpg');
+	        game.load.image('flag_US', imgsrc+'flag/UNST.jpg');
+	        game.load.image('flag_FR', imgsrc+'flag/FRAN.jpg');
+
+	        //scenario
+	        game.load.image('bgimage', imgsrc+'bg.jpg');
+	        game.load.image('bgmap', imgsrc+'bg_map.png');
+	        game.load.image('cloud', imgsrc+'cloud.png');
+	        game.load.image('floor', imgsrc+'floor.png');
+	        game.load.image('road', imgsrc+'road.png');
+	        
+	        //game phases buttons list
+	        game.load.image('game1c', imgsrc+'game/one-c.png');
+	        game.load.image('game2c', imgsrc+'game/two-c.png');
+	        game.load.image('game3c', imgsrc+'game/three-c.png');
+	        game.load.image('game4c', imgsrc+'game/four-c.png');
+	        game.load.image('game1s', imgsrc+'game/one-s.png');
+	        game.load.image('game2s', imgsrc+'game/two-s.png');
+	        game.load.image('game3s', imgsrc+'game/three-s.png');
+	        game.load.image('game4s', imgsrc+'game/four-s.png');
+	        game.load.image('game5s', imgsrc+'game/five-s.png');
+	        
+	        //header menu buttons
+	        game.load.image('back', imgsrc+'menu/back.png');
+	        game.load.image('home', imgsrc+'menu/home.png');
+	        game.load.image('info', imgsrc+'menu/info.png');
+	        game.load.image('world', imgsrc+'menu/language.png');
+	        game.load.image('list', imgsrc+'menu/menu.png');
+	        game.load.image('help', imgsrc+'menu/help.png');
+	        game.load.image('pgbar', imgsrc+'menu/progressBar.png');
+	        game.load.image('block', imgsrc+'menu/block.png');
+			game.load.spritesheet('audio', imgsrc+'menu/audio_48x48.png',48,48,2);
+
+	        //operators
+	        game.load.image('add', imgsrc+'operator/add.png');
+	        game.load.image('subtract', imgsrc+'operator/subtract.png');
+	        game.load.image('separator', imgsrc+'operator/separator.png');
+	        game.load.image('equal', imgsrc+'operator/equal.png');
+	        
+	        //feedback
+	        game.load.image('h_arrow', imgsrc+'help/arrow.png');
+	        game.load.image('h_double', imgsrc+'help/double.png');
+	        game.load.image('h_error', imgsrc+'help/error.png');
+	        game.load.image('h_ok', imgsrc+'help/ok.png');
+	        game.load.image('down', imgsrc+'help/down.png');        
+	        game.load.image('pointer', imgsrc+'help/pointer.png');
+	        
+	        // Loading assets based on language        
+	        game.load.spritesheet('kid_run', imgsrc+'kid/run.png', 82, 178, 12);
+	        game.load.spritesheet('kid_walk', imgsrc+'kid/walk.png', 78, 175, 24);
+	        game.load.spritesheet('kid_lost', imgsrc+'kid/lost.png', 72, 170, 6);
+	        game.load.spritesheet('tractor', imgsrc+'tractor/frame.png', 201, 144, 10);
+	        game.load.image('balloon', imgsrc+'airballoon_upper.png');
+	        game.load.image('balloon_basket', imgsrc+'airballoon_base.png');
+	        game.load.image('birch', imgsrc+'birch.png');
+	        game.load.image('flag', imgsrc+'flag.png');
+	        game.load.image('house', imgsrc+'house.png');
+	        game.load.image('place_a', imgsrc+'place_a.png');
+	        game.load.image('place_b', imgsrc+'place_b.png');
+	        game.load.image('garage', imgsrc+'garage.png');
+	        game.load.image('farm', imgsrc+'farm.png');
+	        game.load.image('rock', imgsrc+'rock.png');
+	        game.load.image('school', imgsrc+'school.png');
+	        game.load.image('sign', imgsrc+'sign.png');
+	        game.load.image('tree1', imgsrc+'tree.png');
+	        game.load.image('tree2', imgsrc+'tree2.png');
+	        game.load.image('tree3', imgsrc+'tree3.png');
+	        game.load.image('tree4', imgsrc+'tree4.png');
+	        
+	        // Loadind Sound Effects
+	        game.load.audio('sound_ok', ['assets/fx/ok.ogg', 'assets/fx/ok.mp3']);
+	        game.load.audio('sound_error', ['assets/fx/error.ogg', 'assets/fx/error.mp3']);
+	        game.load.audio('sound_beep', ['assets/fx/beep.ogg', 'assets/fx/beep.mp3']);
+    	},
+
+    	create: function(){
+    		game.physics.startSystem(Phaser.Physics.ARCADE);
+		    game.state.start('language');
+    	}
+    };
+
+    //starting to boot game
+    game.state.add('loadAssets', loadAssets); // squareTwo.js
+   	game.state.start('loadAssets');

+ 128 - 103
js/circleOne.js

@@ -2,7 +2,7 @@
 /*
     var menuCircleOne = {
         create: function(){},
-        showOption: function(){},
+        ---------------------------- end of phaser functions
         loadState: function(){},
         loadMap: function(){}
     };
@@ -10,7 +10,7 @@
     var mapCircleOne = {
         create: function(){},
         update: function(){},
-        showOption: function(){},
+        ---------------------------- end of phaser functions
         loadState: function(){},
         loadGame: function()
     };
@@ -25,7 +25,6 @@
         clickCircle: function(){},
         setPlace: function(){},
         postScore: function(){},
-        showOption: function(){},
         loadState: function(){},
         viewHelp: function(){},
         checkOverlap: function(){}
@@ -35,6 +34,7 @@
     var endCircleOne = {
         create: function(){},
         update: function(){},
+        ---------------------------- end of phaser functions
         verPrincipal: function(){},
         verMenu: function(){}
     };
@@ -43,40 +43,57 @@
 // Kid and Circle states, games 1 and 2
 
 /****************************** MENU ****************************/
-
 var stairsPlus, stairsMinus, stairsMixed;
 
 var menuCircleOne = {
+    
     create: function() {
         
         // Creating sound variable
         var beepSound = game.add.audio('sound_beep');
-        
-        // Reading dictionary
-        var words = game.cache.getJSON('dictionary');
                 
         // Menu options
-          //information label
-        m_info = game.add.text(14, 53, "", { font: "20px Arial", fill: "#330000", align: "center" });
-          // Return to language button
-        m_world = game.add.sprite(10, 10, 'world'); 
-        m_world.inputEnabled = true;
-        m_world.input.useHandCursor = true;
-        m_world.events.onInputDown.add(this.loadState, {state: "boot", beep: beepSound});
-        m_world.events.onInputOver.add(this.showOption, {message: words.menu_world});
-        m_world.events.onInputOut.add(this.showOption, {message: ""});
-          // Return to menu button
-        m_list = game.add.sprite(60, 10, 'list'); 
+        //information label
+        m_info_left = game.add.text(14, 53, "", { font: "20px Arial", fill: "#330000", align: "center" });
+        
+        m_info_right = game.add.text(game.world.width - 10, 53, "", { font: "20px Arial", fill: "#330000", align: "right" });
+        m_info_right.anchor.setTo(1,0.02);
+
+        // Return to menu button
+        m_list = game.add.sprite(10, 10, 'list'); 
         m_list.inputEnabled = true;
         m_list.input.useHandCursor = true;
         m_list.events.onInputDown.add(this.loadState, {state: "menu", beep: beepSound});
-        m_list.events.onInputOver.add(this.showOption, {message: words.menu_list});
-        m_list.events.onInputOut.add(this.showOption, {message: ""});
+        m_list.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_list});
+        m_list.events.onInputOut.add(function(){ this.m_info_left.text = ""});
+        // Return to diffculty
+        m_back = game.add.sprite(60, 10, 'back'); 
+        m_back.inputEnabled = true;
+        m_back.input.useHandCursor = true;
+        m_back.events.onInputDown.add(this.loadState, {state: "menuCOne", beep: beepSound});
+        m_back.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_back});
+        m_back.events.onInputOut.add(function(){ this.m_info_left.text = ""});
+
+        // Return to language button
+        m_world = game.add.sprite(game.world.width - 120, 10, 'world'); 
+        m_world.inputEnabled = true;
+        m_world.input.useHandCursor = true;
+        m_world.events.onInputDown.add(this.loadState, {state: "language", beep: beepSound});
+        m_world.events.onInputOver.add(function(){ this.m_info_right.text = lang.menu_world });
+        m_world.events.onInputOut.add(function(){ this.m_info_right.text = "" });
+        // change audio status button
+        m_audio = game.add.sprite(game.world.width - 60, 10, 'audio');
+        audioStatus ? m_audio.frame = 0 : m_audio.frame = 1;
+        m_audio.inputEnabled = true;
+        m_audio.input.useHandCursor = true;
+        m_audio.events.onInputDown.add(function(){ if(audioStatus){ audioStatus=false; m_audio.frame = 1; }else{ audioStatus=true; m_audio.frame = 0; }});
+        m_audio.events.onInputOver.add(function(){ this.m_info_right.text = lang.audio });
+        m_audio.events.onInputOut.add(function(){ this.m_info_right.text = "" });
         
         // Setting title
         var style = { font: '28px Arial', fill: '#00804d'};
-        var title = game.add.text(860, 40, words.game_menu_title, style);
-        title.anchor.setTo(1, 0.5);
+        var title = game.add.text(game.world.centerX, 40, lang.game_menu_title, style);
+        title.anchor.setTo(0.5, 0.5);
                 
         //Showing Games and Levels
         var maxHeight = 120; //Max height of a stair
@@ -209,19 +226,18 @@ var menuCircleOne = {
         } 
     },
     
-    //Navigation functions,
-    showOption: function(){
-        m_info.text = this.message;
-    },    
-    
     loadState: function(){
-        this.beep.play();
+        if(audioStatus){
+            this.beep.play();
+        }
         game.state.start(this.state);
     },
         
     //MapLoading function
     loadMap: function(){
-        this.beep.play();
+        if(audioStatus){
+            this.beep.play();
+        }
         onePosition = 0; //Map position
         oneMove = true; //Move no next point
         oneDifficulty  = this.difficulty; //Number of difficulty (1 to 5)
@@ -242,38 +258,30 @@ var mapCircleOne = {
         
         // Creating sound variable
         beepSound = game.add.audio('sound_beep');
-        
-        // Reading dictionary
-        var words = game.cache.getJSON('dictionary');
 
         // Background
         game.add.image(0, 40, 'bgmap');
         
-        if(oneMenu){ //IF not url game
-            // Menu options
-              //information label
-            m_info = game.add.text(14, 53, "", { font: "20px Arial", fill: "#330000", align: "center" });
-              // Return to language button
-            m_world = game.add.sprite(10, 10, 'world'); 
-            m_world.inputEnabled = true;
-            m_world.input.useHandCursor = true;
-            m_world.events.onInputDown.add(this.loadState, {state: "boot", beep: beepSound});
-            m_world.events.onInputOver.add(this.showOption, {message: words.menu_world});
-            m_world.events.onInputOut.add(this.showOption, {message: ""});
-              // Return to menu button
-            m_list = game.add.sprite(60, 10, 'list'); 
+        // Menu options
+        //information label
+        m_info_left = game.add.text(14, 53, "", { font: "20px Arial", fill: "#330000", align: "center" });
+
+        if(oneMenu){
+            // Return to menu button
+            m_list = game.add.sprite(10, 10, 'list'); 
             m_list.inputEnabled = true;
             m_list.input.useHandCursor = true;
             m_list.events.onInputDown.add(this.loadState, {state: "menu", beep: beepSound});
-            m_list.events.onInputOver.add(this.showOption, {message: words.menu_list});
-            m_list.events.onInputOut.add(this.showOption, {message: ""});
-              // Return to diffculty
-            m_back = game.add.sprite(110, 10, 'back'); 
+            m_list.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_list});
+            m_list.events.onInputOut.add(function(){ this.m_info_left.text = ""});
+            // Return to diffculty
+            m_back = game.add.sprite(60, 10, 'back'); 
             m_back.inputEnabled = true;
             m_back.input.useHandCursor = true;
             m_back.events.onInputDown.add(this.loadState, {state: "menuCOne", beep: beepSound});
-            m_back.events.onInputOver.add(this.showOption, {message: words.menu_back});
-            m_back.events.onInputOut.add(this.showOption, {message: ""});
+            m_back.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_back});
+            m_back.events.onInputOut.add(function(){ this.m_info_left.text = ""});
+
         }
         
         // Styles for labels
@@ -288,7 +296,7 @@ var mapCircleOne = {
             block.scale.setTo(2.5, 1); //Scaling to double width
         }
         game.add.text(840, 10, percentText+'%', styleMenu);
-        game.add.text(670, 10, words.difficulty + ' ' + oneDifficulty, styleMenu).anchor.setTo(1,0);
+        game.add.text(670, 10, lang.difficulty + ' ' + oneDifficulty, styleMenu).anchor.setTo(1,0);
         game.add.image(680, 10, 'pgbar');
         
          //Road
@@ -405,18 +413,18 @@ var mapCircleOne = {
     
     //Navigation functions,
     
-    showOption: function(){
-        m_info.text = this.message;
-    },    
-    
     loadState: function(){
-        this.beep.play();
+        if(audioStatus){
+            this.beep.play();
+        }
         game.state.start(this.state);
     },
         
     //MapLoading function
     loadGame: function(){
-        beepSound.play();
+        if(audioStatus){
+            beepSound.play();
+        }
         if(onePosition<5){
             game.state.start('gameCOne');
         }else{
@@ -426,18 +434,20 @@ var mapCircleOne = {
 };
 
 /****************************** GAME ****************************/
-
-var okSound, errorSound; //sounds
 var startX; //start position
 var clicked, hideLabels, animate, checkCollide, result, hasFigure; //control variables
+var detail;
+var endPosition;
+var fractionClicked, fractionIndex;
+//Balloon and blocks control
+var blocks, maxBlocks, numBlocks, curBlock, blockDirection, blockDistance, blockLabel, blockSeparator;
+
+var blockSize, blockAngle, blockTraceColor;
 var fly, flyCounter, flyend; //flyvariables
 var trace; //circle trace
+var numPlus, endIndex;
 var kid_walk, balloon, basket;
-//Balloon and blocks control
-var maxBlocks, blockSize, blocks, numBlocks, curBlock, blockDirection, blockDistance, blockLabel, blockSeparator, blockAngle, blockTraceColor, endPosition;
-var balloonPlace, fractionClicked, fractionIndex, numPlus, endIndex;
-var okImg, errorImg;
-var detail;
+var balloonPlace;
 
 var gameCircleOne = {
 
@@ -454,9 +464,6 @@ var gameCircleOne = {
         beepSound = game.add.audio('sound_beep');
         okSound = game.add.audio('sound_ok');
         errorSound = game.add.audio('sound_error');
-        
-        // Reading dictionary
-        var words = game.cache.getJSON('dictionary');
 
         // Background
         game.add.image(0, 0, 'bgimage');
@@ -674,39 +681,51 @@ var gameCircleOne = {
         basket.anchor.setTo(0.5, 0.5);
         
         // Menu options
-          //information label
-        m_info = game.add.text(14, 53, "", { font: "20px Arial", fill: "#330000", align: "center" });
+        //information label
+        m_info_left = game.add.text(14, 53, "", { font: "20px Arial", fill: "#330000", align: "center" });
         
+        m_info_right = game.add.text(game.world.width - 10, 53, "", { font: "20px Arial", fill: "#330000", align: "right" });
+        m_info_right.anchor.setTo(1,0.02);
+
         if(oneMenu){
-              // Return to language button
-            m_world = game.add.sprite(10, 10, 'world'); 
-            m_world.inputEnabled = true;
-            m_world.input.useHandCursor = true;
-            m_world.events.onInputDown.add(this.loadState, {state: "boot", beep: beepSound});
-            m_world.events.onInputOver.add(this.showOption, {message: words.menu_world});
-            m_world.events.onInputOut.add(this.showOption, {message: ""});
-              // Return to menu button
-            m_list = game.add.sprite(60, 10, 'list'); 
+            // Return to menu button
+            m_list = game.add.sprite(10, 10, 'list'); 
             m_list.inputEnabled = true;
             m_list.input.useHandCursor = true;
             m_list.events.onInputDown.add(this.loadState, {state: "menu", beep: beepSound});
-            m_list.events.onInputOver.add(this.showOption, {message: words.menu_list});
-            m_list.events.onInputOut.add(this.showOption, {message: ""});
-              // Return to diffculty
-            m_back = game.add.sprite(110, 10, 'back'); 
+            m_list.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_list});
+            m_list.events.onInputOut.add(function(){ this.m_info_left.text = ""});
+            // Return to diffculty
+            m_back = game.add.sprite(60, 10, 'back'); 
             m_back.inputEnabled = true;
             m_back.input.useHandCursor = true;
             m_back.events.onInputDown.add(this.loadState, {state: "menuCOne", beep: beepSound});
-            m_back.events.onInputOver.add(this.showOption, {message: words.menu_back});
-            m_back.events.onInputOut.add(this.showOption, {message: ""});
+            m_back.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_back});
+            m_back.events.onInputOut.add(function(){ this.m_info_left.text = ""});
+
+            // Return to language button
+            m_world = game.add.sprite(game.world.width - 120, 10, 'world'); 
+            m_world.inputEnabled = true;
+            m_world.input.useHandCursor = true;
+            m_world.events.onInputDown.add(this.loadState, {state: "language", beep: beepSound});
+            m_world.events.onInputOver.add(function(){ this.m_info_right.text = lang.menu_world });
+            m_world.events.onInputOut.add(function(){ this.m_info_right.text = "" });
+            // change audio status button
+            m_audio = game.add.sprite(game.world.width - 60, 10, 'audio');
+            audioStatus ? m_audio.frame = 0 : m_audio.frame = 1;
+            m_audio.inputEnabled = true;
+            m_audio.input.useHandCursor = true;
+            m_audio.events.onInputDown.add(function(){ if(audioStatus){ audioStatus=false; m_audio.frame = 1; }else{ audioStatus=true; m_audio.frame = 0; }});
+            m_audio.events.onInputOver.add(function(){ this.m_info_right.text = lang.audio });
+            m_audio.events.onInputOut.add(function(){ this.m_info_right.text = "" });
         }
          // Help button
-        m_help = game.add.sprite(160, 10, 'help');
+        m_help = game.add.sprite(110, 10, 'help');
         m_help.inputEnabled = true;
         m_help.input.useHandCursor = true;
         m_help.events.onInputDown.add(this.viewHelp, {beep: this.beepSound});
-        m_help.events.onInputOver.add(this.showOption, {message: words.menu_help});
-        m_help.events.onInputOut.add(this.showOption, {message: ""});
+        m_help.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_help});
+        m_help.events.onInputOut.add(function(){ this.m_info_left.text = ""});
         
         //ok and error images
         okImg = game.add.image(game.world.centerX, game.world.centerY, 'h_ok');
@@ -727,7 +746,9 @@ var gameCircleOne = {
                     balloon.alpha = 1;
                     clicked = true;
                     animate = true;
-                    beepSound.play();
+                    if(audioStatus){
+                        beepSound.play();
+                    }
                     if(blockDirection[curBlock]=='Right'){
                         kid_walk.animations.play('right', 6, true);
                     }else{
@@ -839,10 +860,14 @@ var gameCircleOne = {
             
             if(flyCounter==0){
                 if(result){
-                    okSound.play();
+                    if(audioStatus){
+                        okSound.play();
+                    }
                     okImg.alpha = 1;
                 }else{
-                    errorSound.play();
+                    if(audioStatus){
+                        errorSound.play();
+                    }
                     errorImg.alpha = 1;
                 }
             }
@@ -912,7 +937,9 @@ var gameCircleOne = {
             balloon.alpha = 1;
             clicked = true;
             animate = true;
-            beepSound.play();
+            if(audioStatus){
+                beepSound.play();
+            }
             if(blockDirection[curBlock]=='Right'){
                 kid_walk.animations.play('right', 6, true);
             }else{
@@ -935,7 +962,9 @@ var gameCircleOne = {
             balloon.alpha = 1;
             clicked = true;
             animate = true;
-            beepSound.play();
+            if(audioStatus){
+                beepSound.play();
+            }
             if(blockDirection[curBlock]=='Right'){
                 kid_walk.animations.play('right', 6, true);
             }else{
@@ -974,14 +1003,12 @@ var gameCircleOne = {
         console.log("processing...");
     },
     
-    //Navigation functions,
-    
-    showOption: function(){
-        m_info.text = this.message;
-    },    
+    //Navigation functions, 
     
     loadState: function(){
-        this.beep.play();
+        if(audioStatus){
+            this.beep.play();
+        }
         game.state.start(this.state);
     },
         
@@ -1014,15 +1041,13 @@ var gameCircleOne = {
 /****************************** END ****************************/
 
 var endCircleOne = {
+    
     create: function() {  
         
         // Creating sound variable
         beepSound = game.add.audio('sound_beep');
         okSound = game.add.audio('sound_ok');
         errorSound = game.add.audio('sound_error');
-        
-        // Reading dictionary
-        var words = game.cache.getJSON('dictionary');
 
         // Background
         game.add.image(0, 0, 'bgimage');
@@ -1048,7 +1073,7 @@ var endCircleOne = {
             block.scale.setTo(2, 1); //Scaling to double width
         }
         game.add.text(820, 10, '100%', styleMenu);
-        game.add.text(660, 10, words.difficulty + ' ' + oneDifficulty, styleMenu).anchor.setTo(1,0);
+        game.add.text(660, 10, lang.difficulty + ' ' + oneDifficulty, styleMenu).anchor.setTo(1,0);
         game.add.image(670, 10, 'pgbar');
         
         //School and trees

+ 34 - 28
js/menu.js

@@ -1,8 +1,6 @@
 
 var menu1, menu2, menu3, menu4;
-var m_info, m_world, m_menu, m_back, m_help;
-var beepSound;
-var words;
+var m_info, m_world, m_menu, m_back, m_help, m_audio;
 var lbl_game;
 
 /*
@@ -12,7 +10,6 @@ var lbl_game;
         ---------------------------- end of phaser functions
         showTitle: function(){},
         clearTitle: function(){},
-        showOption: function(){},
         loadState: function(){}
     }
 */
@@ -26,11 +23,11 @@ var menuState = {
         beepSound = game.add.audio('sound_beep');
         
         // Reading dictionary
-        words = game.cache.getJSON('dictionary');
+        lang = game.cache.getJSON('dictionary');
         
         // Title
         var style = { font: "32px Arial", fill: "#00804d", align: "center" };
-        var title = game.add.text(this.game.world.centerX, 80, words.menu_title, style);
+        var title = game.add.text(this.game.world.centerX, 80, lang.menu_title, style);
         title.anchor.setTo(0.5,0.5);
         
         // Subtitle : game mode 
@@ -38,20 +35,30 @@ var menuState = {
         lbl_game = game.add.text(this.game.world.centerX, 110, "", style_game);
         lbl_game.anchor.setTo(0.5,0.5);
         
-        var player_info = game.add.text(this.game.world.centerX, 40, words.welcome + ", " + username + "!", { font: "20px Arial", fill: "#330000", align: "center" });        
+        var player_info = game.add.text(this.game.world.centerX, 40, lang.welcome + ", " + username + "!", { font: "20px Arial", fill: "#330000", align: "center" });        
         player_info.anchor.setTo(0.5,0.5);
 
         // Menu options
 
-         // button : return to select button menu
-        m_info = game.add.text(14, 53, "", { font: "20px Arial", fill: "#330000", align: "center" });
-        m_world = game.add.sprite(10, 10, 'world'); 
+        //information label
+        m_info_right = game.add.text(game.world.width - 10, 53, "", { font: "20px Arial", fill: "#330000", align: "right" });
+        m_info_right.anchor.setTo(1,0.02);
+        // Return to language button
+        m_world = game.add.sprite(game.world.width - 120, 10, 'world'); 
         m_world.inputEnabled = true;
         m_world.input.useHandCursor = true;
-        m_world.events.onInputDown.add(this.loadState, {state: "boot", beep: beepSound});
-        m_world.events.onInputOver.add(this.showOption, {message: words.menu_world});
-        m_world.events.onInputOut.add(this.showOption, {message: ""});
-                
+        m_world.events.onInputDown.add(this.loadState, {state: "language", beep: beepSound});
+        m_world.events.onInputOver.add(function(){ this.m_info_right.text = lang.menu_world });
+        m_world.events.onInputOut.add(function(){ this.m_info_right.text = "" });
+              
+        m_audio = game.add.sprite(game.world.width - 60, 10, 'audio');
+        audioStatus ? m_audio.frame = 0 : m_audio.frame = 1;
+        m_audio.inputEnabled = true;
+        m_audio.input.useHandCursor = true;
+        m_audio.events.onInputDown.add(function(){ if(audioStatus){ audioStatus=false; m_audio.frame = 1; }else{ audioStatus=true; m_audio.frame = 0; }});
+        m_audio.events.onInputOver.add(function(){ this.m_info_right.text = lang.audio });
+        m_audio.events.onInputOut.add(function(){ this.m_info_right.text = "" });
+
         //game buttons 
 
         // loading button sprites
@@ -140,8 +147,10 @@ var menuState = {
     
     //calls the selected game menu screen
     loadGame: function(){
-        
-        this.beep.play();
+        if(audioStatus){
+            this.beep.play();
+        }
+
         if( (this.num==1 || this.num==2) && this.shape=="Circle"){
             oneShape = this.shape;
             oneLabel = this.label;
@@ -190,9 +199,9 @@ var menuState = {
         }
         
         if(this.shape=="Circle"){
-            title += words.circle_name;
+            title += lang.circle_name;
         }else if(this.shape=="Square"){
-            title += words.square_name;
+            title += lang.square_name;
         }
         
         if(type!=""){
@@ -202,9 +211,9 @@ var menuState = {
         
         if(this.label){
                      //-    sem/com                  legendas
-            title += " - " + words.with_name + " " + words.label_name;
+            title += " - " + lang.with_name + " " + lang.label_name;
         }else{
-            title += " - " + words.without_name + " " + words.label_name;
+            title += " - " + lang.without_name + " " + lang.label_name;
         }
         
         lbl_game.text = title;
@@ -214,14 +223,11 @@ var menuState = {
         lbl_game.text = "";
     },
     
-    showOption: function(){
-        m_info.text = this.message;
-    },    
-    
     loadState: function(){
-        this.beep.play();
+        if(audioStatus){
+            this.beep.play();
+        }
         game.state.start(this.state);
-    }
-    
-};
+    },
 
+};

+ 195 - 0
js/preMenu.js

@@ -0,0 +1,195 @@
+
+var errorEmptyName;
+
+/*
+    var langState = {
+        create: function(){},
+        --------------------------------------- end of phaser functions
+        setLang: function(){} //calls loadState
+    };
+    
+    var loadState = {
+        preload: function(){},
+        create: function(){} //calls nameState
+        -------------------------------------- end of phaser functions
+    };
+        
+    var nameState = {
+        preload: function(){},
+        create: function(){},
+        ------------------------------------------------ end of phaser functions
+        ready: function(){} //calls menu.js -> menuState
+    };
+*/
+
+// "choose language" screen
+var langState = {
+
+    create: function() {
+
+        game.stage.backgroundColor = '#cce5ff';
+        
+        var style = { font: '28px Arial', fill: '#00804d', align: 'center' };
+
+        //pt_BR
+        var title1 = game.add.text(this.game.world.centerX - 220, this.game.world.centerY - 100, 'FRAÇÕES  ', style);
+        title1.anchor.setTo(1, 0.5);
+        var flag1 = game.add.sprite(this.game.world.centerX - 220, this.game.world.centerY - 100, 'flag_BR');       
+        flag1.anchor.setTo(0, 0.5);
+        flag1.inputEnabled = true;
+        flag1.input.useHandCursor = true;
+        flag1.events.onInputDown.add(this.setLang,{lang:'pt_BR'});
+
+        //es_PE
+        var title2 = game.add.text(this.game.world.centerX + 200, this.game.world.centerY - 100, 'FRACCIONES  ', style);
+        title2.anchor.setTo(1, 0.5);
+        var flag2 = game.add.sprite(this.game.world.centerX + 200, this.game.world.centerY - 100, 'flag_PE');       
+        flag2.anchor.setTo(0, 0.5);
+        flag2.inputEnabled = true;
+        flag2.input.useHandCursor = true;
+        flag2.events.onInputDown.add(this.setLang,{lang:'es_PE'});
+
+        //en_US
+        var title3 = game.add.text(this.game.world.centerX - 220, this.game.world.centerY + 100, 'FRACTIONS  ', style);
+        title3.anchor.setTo(1, 0.5);
+        var flag3 = game.add.sprite(this.game.world.centerX - 220, this.game.world.centerY + 100, 'flag_US');       
+        flag3.anchor.setTo(0, 0.5);
+        flag3.inputEnabled = true;
+        flag3.input.useHandCursor = true;
+        flag3.events.onInputDown.add(this.setLang,{lang:'en_US'});
+
+        //fr_FR
+        var title4 = game.add.text(this.game.world.centerX + 200, this.game.world.centerY + 100, 'FRACTIONS  ', style);
+        title4.anchor.setTo(1, 0.5);
+        var flag4 = game.add.sprite(this.game.world.centerX + 200, this.game.world.centerY + 100, 'flag_FR');       
+        flag4.anchor.setTo(0, 0.5);
+        flag4.inputEnabled = true;
+        flag4.input.useHandCursor = true;
+        flag4.events.onInputDown.add(this.setLang,{lang:'fr_FR'});
+        
+    },
+    
+    setLang: function(){
+        //set language
+        lang = this.lang;
+        //start resource loading
+        game.state.start('load');
+    }
+
+};
+
+// "loading" screen
+var loadState = {
+    
+    preload: function() {
+        
+        // Displaying the progress bar
+        var progressBar = game.add.sprite(game.world.centerX, game.world.centerY, 'progressBar');
+        progressBar.anchor.setTo(0.5, 0.5);
+        game.load.setPreloadSprite(progressBar);
+        
+        // Loading dictionary
+        game.load.json('dictionary', 'assets/languages/'+lang+'.json');
+        
+    },
+
+    create: function() {  
+        // gets selected language from json
+        lang = game.cache.getJSON('dictionary');
+        audio_lang_aux = lang.audio_on;
+        game.state.start('name');
+    }
+
+};
+
+// "username" screen
+var nameState = {
+
+    create: function() {
+                        
+        var style = { font: '30px Arial', fill: '#00804d', align: 'center' };
+        var styleName = { font: '44px Arial', fill: '#000000', align: 'center' };
+        
+        // title
+        var title = game.add.text(this.game.world.centerX, this.game.world.centerY - 100, lang.insert_name, style);
+        title.anchor.setTo(0.5);
+        
+        // "READY" button
+        var 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);
+        btn.alpha = 0.5;
+        btn.endFill();
+        
+        btn.inputEnabled = true;
+        btn.input.useHandCursor = true;
+        btn.events.onInputDown.add(this.nameIsEmpty, null);
+        
+        var 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);
+
+        errorEmptyName = game.add.text(this.game.world.centerX, this.game.world.centerY - 70, "", {font: '18px Arial', fill: '#330000', align: 'center'});
+        errorEmptyName.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; 
+            //se apertar enter vai para ready, assim como o botão
+            if(keycode == 13){
+                nameState["nameIsEmpty"]();
+            }     
+        });
+    },
+         
+    nameIsEmpty: function() {
+        if(document.getElementById("name_id").value!=""){
+            nameState["ready"]();
+            errorEmptyName.setText("");
+        }else{
+            errorEmptyName.setText(lang.empty_name);
+        }
+
+    },
+
+    //var ready = function readyFunction() {...},
+    //var ready = function() {...},                
+    ready: function() {
+        
+        // saves the typed name on username variable
+        username = document.getElementById("name_id").value;
+        console.log("user is" + username);        
+
+        document.getElementById("text-field-div").style.visibility = "hidden";
+
+        //clears the text field again
+        document.getElementById("name_id").value = "";
+
+        if(oneMenu){ //If menu, normal game
+            // Go to the menu state
+            game.state.start('menu');
+        }else{ //parameters game
+            if(oneShape=="Circle"){
+                game.state.start("mapCOne");
+            }else if(oneShape=="Square"){
+                if(oneOperator=='Mixed'){
+                    twoPosition = 0;
+                    twoMove = true;
+                    twoDifficulty = oneDifficulty; 
+                    twoOperator= "";
+                    twoLabel= false;
+                    twoShape = oneShape;
+                    twoType = oneType;
+                    twoMenu = false;
+                    
+                    game.state.start("mapSTwo");
+                }else{
+                    game.state.start("mapSOne");
+                }
+            }
+            
+        }
+        
+    }
+
+};

+ 136 - 107
js/squareOne.js

@@ -2,7 +2,7 @@
 /*
     var menuSquareOne = {
         create: function(){},
-        showOption: function(){},
+        ---------------------------- end of phaser functions
         loadState: function(){},
         loadMap: function(){}
     };
@@ -10,7 +10,7 @@
     var mapSquareOne = {
         create: function(){},
         update: function(){},
-        showOption: function(){},
+        ---------------------------- end of phaser functions
         loadState: function(){},
         loadGame: function()
     };
@@ -26,7 +26,6 @@
             //setPlace: function(){},
         postScore: function(){},
         update: function(){},
-        showOption: function(){},
         viewHelp: function(){},
             //checkOverlap: function(){}
             //getRndDivisor: function(){}
@@ -35,6 +34,7 @@
     var endSquareOne = {
         create: function(){},
         update: function(){},
+        ---------------------------- end of phaser functions
         verPrincipal: function(){},
         verMenu: function(){}
     };
@@ -46,36 +46,54 @@
 var stairsRight, stairsLeft;
 
 var menuSquareOne = {
+	
     create: function() {
         
         // Creating sound variable
         var beepSound = game.add.audio('sound_beep');
-        
-        // Reading dictionary
-        var words = game.cache.getJSON('dictionary');
           
         // Menu options
-          //information label
-        m_info = game.add.text(14, 53, "", { font: "20px Arial", fill: "#330000", align: "center" });
-          // Return to language button
-        m_world = game.add.sprite(10, 10, 'world'); 
-        m_world.inputEnabled = true;
-        m_world.input.useHandCursor = true;
-        m_world.events.onInputDown.add(this.loadState, {state: "boot", beep: beepSound});
-        m_world.events.onInputOver.add(this.showOption, {message: words.menu_world});
-        m_world.events.onInputOut.add(this.showOption, {message: ""});
-          // Return to menu button
-        m_list = game.add.sprite(60, 10, 'list'); 
+        //information label
+        m_info_left = game.add.text(14, 53, "", { font: "20px Arial", fill: "#330000", align: "center" });
+        
+        m_info_right = game.add.text(game.world.width - 10, 53, "", { font: "20px Arial", fill: "#330000", align: "right" });
+        m_info_right.anchor.setTo(1,0.02);
+
+        // Return to menu button
+        m_list = game.add.sprite(10, 10, 'list'); 
         m_list.inputEnabled = true;
         m_list.input.useHandCursor = true;
         m_list.events.onInputDown.add(this.loadState, {state: "menu", beep: beepSound});
-        m_list.events.onInputOver.add(this.showOption, {message: words.menu_list});
-        m_list.events.onInputOut.add(this.showOption, {message: ""});
+        m_list.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_list});
+        m_list.events.onInputOut.add(function(){ this.m_info_left.text = ""});
+        // Return to diffculty
+        m_back = game.add.sprite(60, 10, 'back'); 
+        m_back.inputEnabled = true;
+        m_back.input.useHandCursor = true;
+        m_back.events.onInputDown.add(this.loadState, {state: "menuSOne", beep: beepSound});
+        m_back.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_back});
+        m_back.events.onInputOut.add(function(){ this.m_info_left.text = ""});
+
+        // Return to language button
+        m_world = game.add.sprite(game.world.width - 120, 10, 'world'); 
+        m_world.inputEnabled = true;
+        m_world.input.useHandCursor = true;
+        m_world.events.onInputDown.add(this.loadState, {state: "language", beep: beepSound});
+        m_world.events.onInputOver.add(function(){ this.m_info_right.text = lang.menu_world });
+        m_world.events.onInputOut.add(function(){ this.m_info_right.text = "" });
+        // change audio status button
+        m_audio = game.add.sprite(game.world.width - 60, 10, 'audio');
+        audioStatus ? m_audio.frame = 0 : m_audio.frame = 1;
+        m_audio.inputEnabled = true;
+        m_audio.input.useHandCursor = true;
+        m_audio.events.onInputDown.add(function(){ if(audioStatus){ audioStatus=false; m_audio.frame = 1; }else{ audioStatus=true; m_audio.frame = 0; }});
+        m_audio.events.onInputOver.add(function(){ this.m_info_right.text = lang.audio });
+        m_audio.events.onInputOut.add(function(){ this.m_info_right.text = "" });
         
         // Setting title
         var style = { font: '28px Arial', fill: '#00804d'};
-        var title = game.add.text(860, 40, words.game_menu_title, style);
-        title.anchor.setTo(1, 0.5);
+        var title = game.add.text(game.world.centerX, 40, lang.game_menu_title, style);
+        title.anchor.setTo(0.5, 0.5);
         
         //Showing Games and Levels
         var maxHeight = 120; //Max height of a stair
@@ -167,18 +185,18 @@ var menuSquareOne = {
     
     //Navigation functions,
     
-    showOption: function(){
-        m_info.text = this.message;
-    },    
-    
     loadState: function(){
-        this.beep.play();
+        if(audioStatus){
+            this.beep.play();
+        }
         game.state.start(this.state);
     },
         
     //MapLoading function
     loadMap: function(){
-        this.beep.play();
+        if(audioStatus){
+            this.beep.play();
+        }
         onePosition = 0; //Map position
         oneMove = true; //Move no next point
         oneDifficulty  = this.difficulty; //Number of difficulty (1 to 5)
@@ -195,42 +213,35 @@ var menuSquareOne = {
 /****************************** MAP ****************************/
 
 var mapSquareOne = {
+
     create: function() {
                 
         // Creating sound variable
         beepSound = game.add.audio('sound_beep');
-        
-        // Reading dictionary
-        var words = game.cache.getJSON('dictionary');
 
         // Background
         game.add.image(0, 40, 'bgmap');
         
+        // Menu options
+        //information label
+        m_info_left = game.add.text(14, 53, "", { font: "20px Arial", fill: "#330000", align: "center" });
+
         if(oneMenu){
-            // Menu options
-              //information label
-            m_info = game.add.text(14, 53, "", { font: "20px Arial", fill: "#330000", align: "center" });
-              // Return to language button
-            m_world = game.add.sprite(10, 10, 'world'); 
-            m_world.inputEnabled = true;
-            m_world.input.useHandCursor = true;
-            m_world.events.onInputDown.add(this.loadState, {state: "boot", beep: beepSound});
-            m_world.events.onInputOver.add(this.showOption, {message: words.menu_world});
-            m_world.events.onInputOut.add(this.showOption, {message: ""});
-              // Return to menu button
-            m_list = game.add.sprite(60, 10, 'list'); 
+            // Return to menu button
+            m_list = game.add.sprite(10, 10, 'list'); 
             m_list.inputEnabled = true;
             m_list.input.useHandCursor = true;
             m_list.events.onInputDown.add(this.loadState, {state: "menu", beep: beepSound});
-            m_list.events.onInputOver.add(this.showOption, {message: words.menu_list});
-            m_list.events.onInputOut.add(this.showOption, {message: ""});
-              // Return to diffculty
-            m_back = game.add.sprite(110, 10, 'back'); 
+            m_list.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_list});
+            m_list.events.onInputOut.add(function(){ this.m_info_left.text = ""});
+            // Return to diffculty
+            m_back = game.add.sprite(60, 10, 'back'); 
             m_back.inputEnabled = true;
             m_back.input.useHandCursor = true;
             m_back.events.onInputDown.add(this.loadState, {state: "menuSOne", beep: beepSound});
-            m_back.events.onInputOver.add(this.showOption, {message: words.menu_back});
-            m_back.events.onInputOut.add(this.showOption, {message: ""});
+            m_back.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_back});
+            m_back.events.onInputOut.add(function(){ this.m_info_left.text = ""});
+
         }
         
         // Styles for labels
@@ -245,7 +256,7 @@ var mapSquareOne = {
             block.scale.setTo(2, 1); //Scaling to double width
         }
         game.add.text(840, 10, percentText+'%', styleMenu);
-        game.add.text(670, 10, words.difficulty + ' ' + oneDifficulty, styleMenu).anchor.setTo(1,0);
+        game.add.text(670, 10, lang.difficulty + ' ' + oneDifficulty, styleMenu).anchor.setTo(1,0);
         game.add.image(680, 10, 'pgbar');
         
          //Road
@@ -360,39 +371,43 @@ var mapSquareOne = {
         }
     },
     
-    //Navigation functions,
-    
-    showOption: function(){
-        m_info.text = this.message;
-    },    
+    //Navigation functions,  
     
     loadState: function(){
-        this.beep.play();
+        if(audioStatus){
+            this.beep.play();
+        }
         game.state.start(this.state);
     },
         
     //MapLoading function
     loadGame: function(){
-        beepSound.play();
+        if(audioStatus){
+            beepSound.play();
+        }
         if(onePosition<5){
             game.state.start('gameSOne');
         }else{
             game.state.start('endSOne');
         }
     }
+
 };
 
 /****************************** GAME ****************************/
-
-var clicked, hideLabels, animate, checkCollide, result, move, moveCounter, moveEnd, hasFigure;
-var startX, tractor, arrow;
-var maxBlocks, blocks, numBlocks, curBlock, blockDirection, blockDistance, blockLabel, blockSeparator;
-var blockWidth, endPosition, blockIndex;
-var floorBlocks, floorIndex, floorCount, floorClicked;
-var arrowPlace, fractionClicked, fractionIndex;
-var okImg, errorImg;
-var curFloor;
+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 = {
 
@@ -409,9 +424,6 @@ var gameSquareOne = {
         beepSound = game.add.audio('sound_beep');
         okSound = game.add.audio('sound_ok');
         errorSound = game.add.audio('sound_error');
-        
-        // Reading dictionary
-        var words = game.cache.getJSON('dictionary');
 
         // Background
         game.add.image(0, 0, 'bgimage');
@@ -659,41 +671,54 @@ var gameSquareOne = {
             game.add.text(posX, 560, i , stylePlace).anchor.setTo(0.5, 0.5); 
         }
         
+        // Menu options
+        //information label
+        m_info_left = game.add.text(14, 53, "", { font: "20px Arial", fill: "#330000", align: "center" });
+        
+        m_info_right = game.add.text(game.world.width - 10, 53, "", { font: "20px Arial", fill: "#330000", align: "right" });
+        m_info_right.anchor.setTo(1,0.02);
+
         if(oneMenu){
-            // Menu options
-              //information label
-            m_info = game.add.text(14, 53, "", { font: "20px Arial", fill: "#330000", align: "center" });
-              // Return to language button
-            m_world = game.add.sprite(10, 10, 'world'); 
-            m_world.inputEnabled = true;
-            m_world.input.useHandCursor = true;
-            m_world.events.onInputDown.add(this.loadState, {state: "boot", beep: beepSound});
-            m_world.events.onInputOver.add(this.showOption, {message: words.menu_world});
-            m_world.events.onInputOut.add(this.showOption, {message: ""});
-              // Return to menu button
-            m_list = game.add.sprite(60, 10, 'list'); 
+            // Return to menu button
+            m_list = game.add.sprite(10, 10, 'list'); 
             m_list.inputEnabled = true;
             m_list.input.useHandCursor = true;
             m_list.events.onInputDown.add(this.loadState, {state: "menu", beep: beepSound});
-            m_list.events.onInputOver.add(this.showOption, {message: words.menu_list});
-            m_list.events.onInputOut.add(this.showOption, {message: ""});
-              // Return to diffculty
-            m_back = game.add.sprite(110, 10, 'back'); 
+            m_list.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_list});
+            m_list.events.onInputOut.add(function(){ this.m_info_left.text = ""});
+            // Return to diffculty
+            m_back = game.add.sprite(60, 10, 'back'); 
             m_back.inputEnabled = true;
             m_back.input.useHandCursor = true;
             m_back.events.onInputDown.add(this.loadState, {state: "menuSOne", beep: beepSound});
-            m_back.events.onInputOver.add(this.showOption, {message: words.menu_back});
-            m_back.events.onInputOut.add(this.showOption, {message: ""});
+            m_back.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_back});
+            m_back.events.onInputOut.add(function(){ this.m_info_left.text = ""});
+
+            // Return to language button
+            m_world = game.add.sprite(game.world.width - 120, 10, 'world'); 
+            m_world.inputEnabled = true;
+            m_world.input.useHandCursor = true;
+            m_world.events.onInputDown.add(this.loadState, {state: "language", beep: beepSound});
+            m_world.events.onInputOver.add(function(){ this.m_info_right.text = lang.menu_world });
+            m_world.events.onInputOut.add(function(){ this.m_info_right.text = "" });
+            // change audio status button
+            m_audio = game.add.sprite(game.world.width - 60, 10, 'audio');
+            audioStatus ? m_audio.frame = 0 : m_audio.frame = 1;
+            m_audio.inputEnabled = true;
+            m_audio.input.useHandCursor = true;
+            m_audio.events.onInputDown.add(function(){ if(audioStatus){ audioStatus=false; m_audio.frame = 1; }else{ audioStatus=true; m_audio.frame = 0; }});
+            m_audio.events.onInputOver.add(function(){ this.m_info_right.text = lang.audio });
+            m_audio.events.onInputOut.add(function(){ this.m_info_right.text = "" });
         }
          // Help button
-        /*
-        m_help = game.add.sprite(160, 10, 'help');
+        
+        m_help = game.add.sprite(110, 10, 'help');
         m_help.inputEnabled = true;
         m_help.input.useHandCursor = true;
         m_help.events.onInputDown.add(this.viewHelp, {beep: this.beepSound});
-        m_help.events.onInputOver.add(this.showOption, {message: words.menu_help});
-        m_help.events.onInputOut.add(this.showOption, {message: ""});
-        */
+        m_help.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_help});
+        m_help.events.onInputOut.add(function(){ this.m_info_left.text = ""});
+        
         //ok and error images
         okImg = game.add.image(game.world.centerX, game.world.centerY, 'h_ok');
         okImg.anchor.setTo(0.5);
@@ -810,10 +835,14 @@ var gameSquareOne = {
             if(moveCounter==0){
                 if(result){
                     tractor.animations.play('right', 6, true);
-                    okSound.play();
+                    if(audioStatus){
+                        okSound.play();
+                    }
                     okImg.alpha = 1;
                 }else{
-                    errorSound.play();
+                    if(audioStatus){
+                        errorSound.play();
+                    }
                     errorImg.alpha = 1;
                 }
             }
@@ -893,8 +922,9 @@ var gameSquareOne = {
                 arrow.alpha = 1;
                 clicked = true;
                 animate = true;
-                beepSound.play();
-                
+                if(audioStatus){
+                    beepSound.play();
+                }            
                 tractor.animations.play('right', 5, true);
                 
                 if(oneLabel){ //Hiding labels
@@ -934,7 +964,9 @@ var gameSquareOne = {
                 arrow.alpha = 1;
                 clicked = true;
                 animate = true;
-                beepSound.play();
+                if(audioStatus){
+                    beepSound.play();
+                }
                 tractor.animations.play('right', 5, true);
 
                 if(oneLabel){ //Hiding labels
@@ -971,13 +1003,11 @@ var gameSquareOne = {
     },       
     
     //Navigation functions,
-    
-    showOption: function(){
-        m_info.text = this.message;
-    },    
-    
+
     loadState: function(){
-        this.beep.play();
+        if(audioStatus){
+            this.beep.play();
+        }
         game.state.start(this.state);
     },
         
@@ -999,15 +1029,13 @@ var gameSquareOne = {
 /****************************** END ****************************/
 
 var endSquareOne = {
+
     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');
-        
-        // Reading dictionary
-        var words = game.cache.getJSON('dictionary');
 
         // Background
         game.add.image(0, 0, 'bgimage');
@@ -1033,7 +1061,7 @@ var endSquareOne = {
             block.scale.setTo(2, 1); //Scaling to double width
         }
         game.add.text(830, 10, '100%', styleMenu);
-        game.add.text(670, 10, words.difficulty + ' ' + oneDifficulty, styleMenu).anchor.setTo(1,0);
+        game.add.text(670, 10, lang.difficulty + ' ' + oneDifficulty, styleMenu).anchor.setTo(1,0);
         game.add.image(680, 10, 'pgbar');
         
         //Farm and trees
@@ -1071,5 +1099,6 @@ var endSquareOne = {
         if(oneMenu){
             game.state.start('menu');
         }
-    }        
+    }     
+
 };

+ 131 - 104
js/squareTwo.js

@@ -1,8 +1,7 @@
 /*
     var menuSquareTwo = {
         create: function(){},
-        ---
-        showOption: function(){},
+        ---------------------------- end of phaser functions
         loadState: function(){},
         loadMap: function(){}
     };
@@ -10,8 +9,7 @@
     var mapSquareTwo = {
         create: function(){},
         update: function(){},
-        ---
-        showOption: function(){},
+        ---------------------------- end of phaser functions
         loadState: function(){},
         loadGame: function()
     };
@@ -27,7 +25,6 @@
             //setPlace: function(){},
         postScore: function(){},
         update: function(){},
-        showOption: function(){},
         loadState: function(){},
             //viewHelp: function(){},
             //checkOverlap: function(){}
@@ -38,7 +35,7 @@
     var endSquareTwo = {
         create: function(){},
         update: function(){},
-        ---
+        ---------------------------- end of phaser functions
         verPrincipal: function(){},
         verMenu: function(){}
     };
@@ -55,35 +52,49 @@ var menuSquareTwo = {
         
         // Creating sound variable
         var beepSound = game.add.audio('sound_beep');
-        
-        // Reading dictionary
-        var words = game.cache.getJSON('dictionary');
           
         // Menu options
-        
         //information label
-        m_info = game.add.text(14, 53, "", { font: "20px Arial", fill: "#330000", align: "center" });
-        
-        // Return to language button
-        m_world = game.add.sprite(10, 10, 'world'); 
-        m_world.inputEnabled = true;
-        m_world.input.useHandCursor = true;
-        m_world.events.onInputDown.add(this.loadState, {state: "boot", beep: beepSound});
-        m_world.events.onInputOver.add(this.showOption, {message: words.menu_world});
-        m_world.events.onInputOut.add(this.showOption, {message: ""});
+        m_info_left = game.add.text(14, 53, "", { font: "20px Arial", fill: "#330000", align: "center" });
         
+        m_info_right = game.add.text(game.world.width - 10, 53, "", { font: "20px Arial", fill: "#330000", align: "right" });
+        m_info_right.anchor.setTo(1,0.02);
+
         // Return to menu button
-        m_list = game.add.sprite(60, 10, 'list'); 
+        m_list = game.add.sprite(10, 10, 'list'); 
         m_list.inputEnabled = true;
         m_list.input.useHandCursor = true;
         m_list.events.onInputDown.add(this.loadState, {state: "menu", beep: beepSound});
-        m_list.events.onInputOver.add(this.showOption, {message: words.menu_list});
-        m_list.events.onInputOut.add(this.showOption, {message: ""});
+        m_list.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_list});
+        m_list.events.onInputOut.add(function(){ this.m_info_left.text = ""});
+        // Return to diffculty
+        m_back = game.add.sprite(60, 10, 'back'); 
+        m_back.inputEnabled = true;
+        m_back.input.useHandCursor = true;
+        m_back.events.onInputDown.add(this.loadState, {state: "menuSTwo", beep: beepSound});
+        m_back.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_back});
+        m_back.events.onInputOut.add(function(){ this.m_info_left.text = ""});
+
+        // Return to language button
+        m_world = game.add.sprite(game.world.width - 120, 10, 'world'); 
+        m_world.inputEnabled = true;
+        m_world.input.useHandCursor = true;
+        m_world.events.onInputDown.add(this.loadState, {state: "language", beep: beepSound});
+        m_world.events.onInputOver.add(function(){ this.m_info_right.text = lang.menu_world });
+        m_world.events.onInputOut.add(function(){ this.m_info_right.text = "" });
+        // change audio status button
+        m_audio = game.add.sprite(game.world.width - 60, 10, 'audio');
+        audioStatus ? m_audio.frame = 0 : m_audio.frame = 1;
+        m_audio.inputEnabled = true;
+        m_audio.input.useHandCursor = true;
+        m_audio.events.onInputDown.add(function(){ if(audioStatus){ audioStatus=false; m_audio.frame = 1; }else{ audioStatus=true; m_audio.frame = 0; }});
+        m_audio.events.onInputOver.add(function(){ this.m_info_right.text = lang.audio });
+        m_audio.events.onInputOut.add(function(){ this.m_info_right.text = "" });
         
         // Setting title
         var style = { font: '28px Arial', fill: '#00804d'};
-        var title = game.add.text(860, 40, words.game_menu_title, style);
-        title.anchor.setTo(1, 0.5);
+        var title = game.add.text(game.world.centerX, 40, lang.game_menu_title, style);
+        title.anchor.setTo(0.5, 0.5);
         
         //Showing Games and Levels
         var maxHeight = 120;  //Max height of a stair
@@ -186,18 +197,18 @@ var menuSquareTwo = {
     
     //Navigation functions,
     
-    showOption: function(){
-        m_info.text = this.message;
-    },    
-    
     loadState: function(){
-        this.beep.play();
+        if(audioStatus){
+            this.beep.play();
+        }
         game.state.start(this.state);
     },  
         
     //MapLoading function
     loadMap: function(){
-        this.beep.play();
+        if(audioStatus){
+            this.beep.play();
+        }
         twoPosition = 0; //Map position
         twoMove = true; //Move no next point
         twoDifficulty  = this.difficulty; //Number of difficulty (1 to 5)
@@ -207,7 +218,7 @@ var menuSquareTwo = {
         }else{
             game.state.start('unofinal');
         }
-    }
+    },
     
 };
 
@@ -219,38 +230,30 @@ var mapSquareTwo={
                 
         // Creating sound variable
         beepSound = game.add.audio('sound_beep');
-        
-        // Reading dictionary
-        var words = game.cache.getJSON('dictionary');
 
         // Background
         game.add.image(0, 40, 'bgmap');
         
-        if(oneMenu){
-            // Menu options
-              //information label
-            m_info = game.add.text(14, 53, "", { font: "20px Arial", fill: "#330000", align: "center" });
-              // Return to language button
-            m_world = game.add.sprite(10, 10, 'world'); 
-            m_world.inputEnabled = true;
-            m_world.input.useHandCursor = true;
-            m_world.events.onInputDown.add(this.loadState, {state: "boot", beep: beepSound});
-            m_world.events.onInputOver.add(this.showOption, {message: words.menu_world});
-            m_world.events.onInputOut.add(this.showOption, {message: ""});
-              // Return to menu button
-            m_list = game.add.sprite(60, 10, 'list'); 
+        // Menu options
+        //information label
+        m_info_left = game.add.text(14, 53, "", { font: "20px Arial", fill: "#330000", align: "center" });
+
+        if(twoMenu){
+            // Return to menu button
+            m_list = game.add.sprite(10, 10, 'list'); 
             m_list.inputEnabled = true;
             m_list.input.useHandCursor = true;
             m_list.events.onInputDown.add(this.loadState, {state: "menu", beep: beepSound});
-            m_list.events.onInputOver.add(this.showOption, {message: words.menu_list});
-            m_list.events.onInputOut.add(this.showOption, {message: ""});
-              // Return to diffculty
-            m_back = game.add.sprite(110, 10, 'back'); 
+            m_list.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_list});
+            m_list.events.onInputOut.add(function(){ this.m_info_left.text = ""});
+            // Return to diffculty
+            m_back = game.add.sprite(60, 10, 'back'); 
             m_back.inputEnabled = true;
             m_back.input.useHandCursor = true;
             m_back.events.onInputDown.add(this.loadState, {state: "menuSTwo", beep: beepSound});
-            m_back.events.onInputOver.add(this.showOption, {message: words.menu_back});
-            m_back.events.onInputOut.add(this.showOption, {message: ""});
+            m_back.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_back});
+            m_back.events.onInputOut.add(function(){ this.m_info_left.text = ""});
+
         }
         
         // Styles for labels
@@ -265,7 +268,7 @@ var mapSquareTwo={
             block.scale.setTo(2, 1); //Scaling to double width
         }
         game.add.text(840, 10, percentText+'%', styleMenu);
-        game.add.text(670, 10, words.difficulty + ' ' + oneDifficulty, styleMenu).anchor.setTo(1,0);
+        game.add.text(670, 10, lang.difficulty + ' ' + oneDifficulty, styleMenu).anchor.setTo(1,0);
         game.add.image(680, 10, 'pgbar');
         
          //Road
@@ -377,21 +380,20 @@ var mapSquareTwo={
                 twoPosition += 1; //Update position
             }
         }
-    },
-    //Navigation functions
-    
-    showOption: function(){
-        m_info.text = this.message;
-    },    
+    }, 
     
     loadState: function(){
-        this.beep.play();
+        if(audioStatus){
+            this.beep.play();
+        }
         game.state.start(this.state);
     },
         
     //MapLoading function
     loadGame: function(){
-        beepSound.play();
+        if(audioStatus){
+           beepSound.play();
+        }
         if(twoPosition<5){
             game.state.start('gameSTwo');
         }else{
@@ -401,14 +403,12 @@ var mapSquareTwo={
 };
 
 /****************************** GAME ****************************/
-
 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 kid, kidDirection, equals, counter, endCounter;
 var xA, yA, xB, yB, blockW, blockH;
-var okImg, errorImg;
 
 var gameSquareTwo = {
 
@@ -426,9 +426,6 @@ var gameSquareTwo = {
         beepSound = game.add.audio('sound_beep');
         okSound = game.add.audio('sound_ok');
         errorSound = game.add.audio('sound_error');
-        
-        // Reading dictionary
-        var words = game.cache.getJSON('dictionary');
 
         // Background
         game.add.image(0, 0, 'bgimage');
@@ -474,9 +471,12 @@ var gameSquareTwo = {
         //generator
         console.log("----------");
         console.log("Diff " + twoDifficulty + ", ini " + ((twoDifficulty-1)*2+1) + ", end " + ((twoDifficulty-1)*2+3));
+        
         var rPoint = game.rnd.integerInRange((twoDifficulty-1)*2+1,(twoDifficulty-1)*2+3);
         sizeA = points[rPoint];
+        
         console.log("Rpoint " + rPoint + ", val " + sizeA);
+        
         sizeB =  this.getRndDivisor(sizeA);
         blockB = game.rnd.integerInRange(1, sizeB);
         blockA = (sizeA/sizeB) * blockB;
@@ -612,32 +612,44 @@ var gameSquareTwo = {
         fractionB.alpha = 0;
         separatorB.alpha = 0;
         
+        // Menu options
+        //information label
+        m_info_left = game.add.text(14, 53, "", { font: "20px Arial", fill: "#330000", align: "center" });
         
-          //information label
-        m_info = game.add.text(14, 53, "", { font: "20px Arial", fill: "#330000", align: "center" });
-        
+        m_info_right = game.add.text(game.world.width - 10, 53, "", { font: "20px Arial", fill: "#330000", align: "right" });
+        m_info_right.anchor.setTo(1,0.02);
+
         if(twoMenu){
-              // Return to language button
-            m_world = game.add.sprite(10, 10, 'world'); 
-            m_world.inputEnabled = true;
-            m_world.input.useHandCursor = true;
-            m_world.events.onInputDown.add(this.loadState, {state: "boot", beep: beepSound});
-            m_world.events.onInputOver.add(this.showOption, {message: words.menu_world});
-            m_world.events.onInputOut.add(this.showOption, {message: ""});
-              // Return to menu button
-            m_list = game.add.sprite(60, 10, 'list'); 
+            // Return to menu button
+            m_list = game.add.sprite(10, 10, 'list'); 
             m_list.inputEnabled = true;
             m_list.input.useHandCursor = true;
             m_list.events.onInputDown.add(this.loadState, {state: "menu", beep: beepSound});
-            m_list.events.onInputOver.add(this.showOption, {message: words.menu_list});
-            m_list.events.onInputOut.add(this.showOption, {message: ""});
-              // Return to diffculty
-            m_back = game.add.sprite(110, 10, 'back'); 
+            m_list.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_list});
+            m_list.events.onInputOut.add(function(){ this.m_info_left.text = ""});
+            // Return to diffculty
+            m_back = game.add.sprite(60, 10, 'back'); 
             m_back.inputEnabled = true;
             m_back.input.useHandCursor = true;
             m_back.events.onInputDown.add(this.loadState, {state: "menuSTwo", beep: beepSound});
-            m_back.events.onInputOver.add(this.showOption, {message: words.menu_back});
-            m_back.events.onInputOut.add(this.showOption, {message: ""});
+            m_back.events.onInputOver.add(function(){ this.m_info_left.text = lang.menu_back});
+            m_back.events.onInputOut.add(function(){ this.m_info_left.text = ""});
+
+            // Return to language button
+            m_world = game.add.sprite(game.world.width - 120, 10, 'world'); 
+            m_world.inputEnabled = true;
+            m_world.input.useHandCursor = true;
+            m_world.events.onInputDown.add(this.loadState, {state: "language", beep: beepSound});
+            m_world.events.onInputOver.add(function(){ this.m_info_right.text = lang.menu_world });
+            m_world.events.onInputOut.add(function(){ this.m_info_right.text = "" });
+            // change audio status button
+            m_audio = game.add.sprite(game.world.width - 60, 10, 'audio');
+            audioStatus ? m_audio.frame = 0 : m_audio.frame = 1;
+            m_audio.inputEnabled = true;
+            m_audio.input.useHandCursor = true;
+            m_audio.events.onInputDown.add(function(){ if(audioStatus){ audioStatus=false; m_audio.frame = 1; }else{ audioStatus=true; m_audio.frame = 0; }});
+            m_audio.events.onInputOver.add(function(){ this.m_info_right.text = lang.audio });
+            m_audio.events.onInputOut.add(function(){ this.m_info_right.text = "" });
         }
         
         //ok and error images
@@ -715,13 +727,17 @@ var gameSquareTwo = {
                 if((valueA/sizeA) == (valueB/sizeB)){
                     result = true;
                     twoMove = true;
-                    okSound.play();
+                    if(audioStatus){
+                        okSound.play();
+                    }
                     okImg.alpha = 1;
                 //fractions are not equivalent
                 }else{
                     result = false;
                     twoMove = false;
-                    errorSound.play();
+                    if(audioStatus){
+                        errorSound.play();
+                    }
                     kid.animations.stop();
                     errorImg.alpha = 1;
                 }
@@ -752,8 +768,13 @@ var gameSquareTwo = {
     overSquare: function(){
         if(!clickA && this.who=="A"){
             if(this.indice == sizeA-1){
-                errorTextA.setText(words.error_msg);
-                errorTextB.setText("");
+                if(yA==90){
+                    errorTextA.setText(lang.error_msg);
+                    errorTextB.setText("");
+                }else{
+                    errorTextA.setText("");
+                    errorTextB.setText(lang.error_msg);
+                }
             }else{    
                 errorTextA.setText("");
                 errorTextB.setText("");
@@ -772,8 +793,13 @@ var gameSquareTwo = {
 
         if(!clickB && this.who=="B"){
             if(this.indice == sizeB-1){
-                errorTextB.setText(words.error_msg);
-                errorTextA.setText("");
+                if(yA==90){
+                    errorTextA.setText("");
+                    errorTextB.setText(lang.error_msg);
+                }else{
+                    errorTextA.setText(lang.error_msg);
+                    errorTextB.setText("");
+                }
             }else{
                 errorTextA.setText("");
                 errorTextB.setText("");
@@ -818,7 +844,9 @@ var gameSquareTwo = {
                 }
             }
             labelA.alpha = 0;
-            beepSound.play();
+            if(audioStatus){
+                beepSound.play();
+            }
             clickA = true;
             valueA = this.indice+1;
             fractionA.x = xA+(valueA*(blockW/sizeA))+40;
@@ -837,7 +865,9 @@ var gameSquareTwo = {
                 }
             }
             labelB.alpha = 0;
-            beepSound.play();
+            if(audioStatus){
+                beepSound.play();
+            }
             clickB = true;
             valueB = this.indice+1;
             fractionB.x = xB+(valueB*(blockW/sizeB))+40;
@@ -873,18 +903,18 @@ var gameSquareTwo = {
 
     //Navigation functions,
     
-    showOption: function(){
-        m_info.text = this.message;
-    },    
-    
     loadState: function(){
-        this.beep.play();
+        if(audioStatus){
+            this.beep.play();
+        }
         game.state.start(this.state);
     },
     
     //MapLoading function
     loadGame: function(){
-        beepSound.play();
+        if(audioStatus){
+            beepSound.play();
+        }
         if(onePosition<5){
             game.state.start('gameSOne');
         }else{
@@ -903,7 +933,7 @@ var gameSquareTwo = {
         }
         var x = game.rnd.integerInRange(0,p-1);
         return div[x];
-    }
+    },
     
 };
 
@@ -917,9 +947,6 @@ var endSquareTwo = {
         beepSound = game.add.audio('sound_beep');
         okSound = game.add.audio('sound_ok');
         errorSound = game.add.audio('sound_error');
-        
-        // Reading dictionary
-        var words = game.cache.getJSON('dictionary');
 
         // Background
         game.add.image(0, 0, 'bgimage');
@@ -945,7 +972,7 @@ var endSquareTwo = {
             block.scale.setTo(2, 1); //Scaling to double width
         }
         game.add.text(820, 10, '100%', styleMenu);
-        game.add.text(660, 10, words.difficulty + ' ' + oneDifficulty, styleMenu).anchor.setTo(1,0);
+        game.add.text(660, 10, lang.difficulty + ' ' + oneDifficulty, styleMenu).anchor.setTo(1,0);
         game.add.image(670, 10, 'pgbar');
         
         //School and trees