Bladeren bron

change map handling variable names

lairaalmas 1 jaar geleden
bovenliggende
commit
a81e7d7e4f

+ 6 - 5
src/js/games/circleOne.js

@@ -130,8 +130,9 @@ const circleOne = {
 
     // Number of circles
     const max =
-      gameOperation == 'Mixed' || gameMode == 'B' ? 6 : mapPosition + 1;
-    const min = gameOperation == 'Mixed' && mapPosition < 2 ? 2 : mapPosition; // Mixed level has at least 2 fractions
+      gameOperation == 'Mixed' || gameMode == 'B' ? 6 : curMapPosition + 1;
+    const min =
+      gameOperation == 'Mixed' && curMapPosition < 2 ? 2 : curMapPosition; // Mixed level has at least 2 fractions
     const total = game.math.randomInRange(min, max); // Total number of circles
 
     // gameMode 'B' exclusive variables
@@ -484,8 +485,8 @@ const circleOne = {
       if (self.result) self.kid.y -= 2;
 
       if (self.count >= 140) {
-        if (self.result) mapMove = true;
-        else mapMove = false;
+        if (self.result) canGoToNextMapPosition = true;
+        else canGoToNextMapPosition = false;
 
         game.state.start('map');
       }
@@ -701,7 +702,7 @@ const circleOne = {
       '&line_leve=' +
       gameDifficulty +
       '&line_posi=' +
-      mapPosition +
+      curMapPosition +
       '&line_resu=' +
       self.result +
       '&line_time=' +

+ 6 - 6
src/js/games/squareOne.js

@@ -310,8 +310,8 @@ const squareOne = {
       // WHEN REACHED END POSITION calls map state
       if (self.count >= 140) {
         // If CORRECT ANSWER, player goes to next level in map
-        if (self.result) mapMove = true;
-        else mapMove = false;
+        if (self.result) canGoToNextMapPosition = true;
+        else canGoToNextMapPosition = false;
 
         game.state.start('map');
       }
@@ -437,9 +437,9 @@ const squareOne = {
    */
   createStckBlocks: function () {
     let hasBaseDifficulty = false; // Will be true after next for loop if level has at least one '1/difficulty' fraction (if false, restart)
-    const max = gameMode == 'B' ? 10 : mapPosition + 4; // Maximum number of stacked blocks for the level
+    const max = gameMode == 'B' ? 10 : curMapPosition + 4; // Maximum number of stacked blocks for the level
 
-    const total = game.math.randomInRange(mapPosition + 2, max); // Current number of stacked blocks for the level
+    const total = game.math.randomInRange(curMapPosition + 2, max); // Current number of stacked blocks for the level
 
     self.floor.correctXA =
       self.startX + self.defaultBlockWidth * self.direc_level;
@@ -542,7 +542,7 @@ const squareOne = {
         'Stacked blocks: ' +
           total +
           ' (min: ' +
-          (mapPosition + 2) +
+          (curMapPosition + 2) +
           ', max: ' +
           max +
           ')'
@@ -755,7 +755,7 @@ const squareOne = {
       '&line_leve=' +
       gameDifficulty +
       '&line_posi=' +
-      mapPosition +
+      curMapPosition +
       '&line_resu=' +
       self.result +
       '&line_time=' +

+ 3 - 3
src/js/games/squareTwo.js

@@ -368,7 +368,7 @@ const squareTwo = {
           game.add
             .image(context.canvas.width / 2, context.canvas.height / 2, 'ok')
             .anchor(0.5, 0.5);
-          mapMove = true; // Allow character to move to next level in map state
+          canGoToNextMapPosition = true; // Allow character to move to next level in map state
           completedLevels++;
 
           if (debugMode) console.log('Completed Levels: ' + completedLevels);
@@ -379,7 +379,7 @@ const squareTwo = {
           game.add
             .image(context.canvas.width / 2, context.canvas.height / 2, 'error')
             .anchor(0.5, 0.5);
-          mapMove = false; // Doesnt allow character to move to next level in map state
+          canGoToNextMapPosition = false; // Doesnt allow character to move to next level in map state
         }
 
         self.postScore();
@@ -592,7 +592,7 @@ const squareTwo = {
       '&line_leve=' +
       gameDifficulty +
       '&line_posi=' +
-      mapPosition +
+      curMapPosition +
       '&line_resu=' +
       self.result +
       '&line_time=' +

+ 3 - 3
src/js/globals/globals_control.js

@@ -25,7 +25,7 @@
  * ..................(game.levels)......................
  * ......................__|__..........................
  * .....................|.|.|.|.........................
- * ...................0,1,2,3,4,5....................... = mapPosition (map positions)
+ * ...................0,1,2,3,4,5....................... = curMapPosition (map positions)
  * ...................|.........|.......................
  * ................(start)....(end).....................
  **************************************************************/
@@ -100,13 +100,13 @@ let fractionLabel = true;
  * When true, the character can move to next position in the map
  * @type {boolean}
  */
-let mapMove;
+let canGoToNextMapPosition;
 
 /**
  * Character position on the map, aka game levels (1..4: valid; 5: end)
  * @type {number}
  */
-let mapPosition;
+let curMapPosition;
 
 /**
  * Number of finished levels in the map

+ 3 - 3
src/js/globals/globals_functions.js

@@ -225,10 +225,10 @@ const debug = {
 const sendToDatabase = function (extraData) {
   // FOR MOODLE
   if (moodle) {
-    if (self.result) moodleVar.hits[mapPosition - 1]++;
-    else moodleVar.errors[mapPosition - 1]++;
+    if (self.result) moodleVar.hits[curMapPosition - 1]++;
+    else moodleVar.errors[curMapPosition - 1]++;
 
-    moodleVar.time[mapPosition - 1] += game.timer.elapsed;
+    moodleVar.time[curMapPosition - 1] += game.timer.elapsed;
 
     const url = iLMparameters.iLM_PARAM_ServerToGetAnswerURL;
     const grade = '' + getEvaluation();

+ 2 - 2
src/js/menus/menu_custom.js

@@ -125,8 +125,8 @@ const customMenuState = {
               '\n------------------------------'
           );
         }
-        mapPosition = 0; // Map position
-        mapMove = true; // Move no next point
+        curMapPosition = 0; // Map position
+        canGoToNextMapPosition = true; // Move no next point
         completedLevels = 0; // Reset the game progress when entering a new level
         game.state.start('map');
         break;

+ 2 - 2
src/js/moodle/integrationFunctions.js

@@ -243,8 +243,8 @@ const updateGlobalVariables = function (infoGame, infoResults) {
   gameDifficulty = parseInt(infoGame['gameDifficulty']);
   fractionLabel = infoGame['fractionLabel'];
   // Update default values
-  mapPosition = 0;
-  mapMove = true;
+  curMapPosition = 0;
+  canGoToNextMapPosition = true;
   completedLevels = 0;
   // If the assignment WAS previously completed calls 'studentReport' after all is loaded.
   if (infoResults) {

+ 17 - 17
src/js/screens/map.js

@@ -225,7 +225,7 @@ const mapState = {
     // Map positions
     for (let i = 1; i < this.points.x.length - 1; i++) {
       const aux =
-        i < mapPosition || (mapMove && i == mapPosition)
+        i < curMapPosition || (canGoToNextMapPosition && i == curMapPosition)
           ? 'place_on'
           : 'place_off';
 
@@ -250,8 +250,8 @@ const mapState = {
     if (gameName == 'squareOne' || gameName == 'scaleOne') {
       if (gameOperation == 'Plus') {
         this.character = game.add.sprite(
-          this.points.x[mapPosition],
-          this.points.y[mapPosition],
+          this.points.x[curMapPosition],
+          this.points.y[curMapPosition],
           'tractor',
           0,
           0.75
@@ -259,8 +259,8 @@ const mapState = {
         this.character.animation = ['green_tractor', [0, 1, 2, 3, 4], 3];
       } else {
         this.character = game.add.sprite(
-          this.points.x[mapPosition],
-          this.points.y[mapPosition],
+          this.points.x[curMapPosition],
+          this.points.y[curMapPosition],
           'tractor',
           10,
           0.75
@@ -271,8 +271,8 @@ const mapState = {
       this.character.rotate = -30; // 25 anticlock
     } else {
       this.character = game.add.sprite(
-        this.points.x[mapPosition],
-        this.points.y[mapPosition],
+        this.points.x[curMapPosition],
+        this.points.y[curMapPosition],
         'kid_run',
         0,
         0.6
@@ -286,10 +286,10 @@ const mapState = {
     this.count = 0;
 
     const speed = 60;
-    const xA = this.points.x[mapPosition];
-    const yA = this.points.y[mapPosition];
-    const xB = this.points.x[mapPosition + 1];
-    const yB = this.points.y[mapPosition + 1];
+    const xA = this.points.x[curMapPosition];
+    const yA = this.points.y[curMapPosition];
+    const xB = this.points.x[curMapPosition + 1];
+    const yB = this.points.y[curMapPosition + 1];
     self.speedX = (xB - xA) / speed;
     self.speedY = (yA - yB) / speed;
 
@@ -311,18 +311,18 @@ const mapState = {
     if (self.count > 60) {
       // Wait 1 second before moving or staring a game
 
-      if (mapMove) {
+      if (canGoToNextMapPosition) {
         // Move character on screen for 1 second
         self.character.x += self.speedX;
         self.character.y -= self.speedY;
-        if (Math.ceil(self.character.x) >= self.points.x[mapPosition + 1]) {
+        if (Math.ceil(self.character.x) >= self.points.x[curMapPosition + 1]) {
           // Reached next map position
-          mapMove = false;
-          mapPosition++; // Set new next position
+          canGoToNextMapPosition = false;
+          curMapPosition++; // Set new next position
         }
       }
 
-      if (!mapMove) {
+      if (!canGoToNextMapPosition) {
         endUpdate = true;
       }
     }
@@ -340,7 +340,7 @@ const mapState = {
    * Calls game state
    */
   loadGame: function () {
-    if (mapPosition <= 4) game.state.start('' + gameName);
+    if (curMapPosition <= 4) game.state.start('' + gameName);
     else game.state.start('end');
   },