浏览代码

🐛 Fix code layout to play nice with older version of JavaScript

Pedro Tonini Rosenberg Schneider 3 年之前
父节点
当前提交
7078f10201

+ 15 - 10
src/elements/EelementSelector.js

@@ -1,15 +1,20 @@
 class EelementSelector extends Object2D
 {
-    /** @type {Button} */
-    backButton = null;
-    /** @type {Button} */
-    earthButton = null;
-    /** @type {Button} */
-    waterButton = null;
-    /** @type {Button} */
-    fireButton = null;
-    /** @type {Button} */
-    airButton = null;
+    constructor(name)
+    {
+        super(name);
+
+        /** @type {Button} */
+        this.backButton = null;
+        /** @type {Button} */
+        this.earthButton = null;
+        /** @type {Button} */
+        this.waterButton = null;
+        /** @type {Button} */
+        this.fireButton = null;
+        /** @type {Button} */
+        this.airButton = null;
+    }
 
     _setup()
     {

+ 23 - 18
src/elements/earth/EarthMinigameSelector.js

@@ -1,23 +1,28 @@
 class EarthMinigameSelector extends Object2D
 {
-    /** @type {Button} */
-    backButton = null;
-    /** @type {Button} */
-    foodHuntButton = null;
-    /** @type {Button} */
-    letterHuntButton = null;
-    /** @type {Button} */
-    acrofonyButton = null;
-    /** @type {Button} */
-    valise1Button = null;
-    /** @type {Button} */
-    valise2Button = null;
-    /** @type {Button} */
-    valise3Button = null;
-    /** @type {Button} */
-    rebusButton = null;
-    /** @type {Button} */
-    guessButton = null;
+    constructor(name)
+    {
+        super(name);
+
+        /** @type {Button} */
+        this.backButton = null;
+        /** @type {Button} */
+        this.foodHuntButton = null;
+        /** @type {Button} */
+        this.letterHuntButton = null;
+        /** @type {Button} */
+        this.acrofonyButton = null;
+        /** @type {Button} */
+        this.valise1Button = null;
+        /** @type {Button} */
+        this.valise2Button = null;
+        /** @type {Button} */
+        this.valise3Button = null;
+        /** @type {Button} */
+        this.rebusButton = null;
+        /** @type {Button} */
+        this.guessButton = null;
+    }
 
     _setup()
     {

+ 7 - 2
src/elements/earth/foodHunt/FoodHuntBasket.js

@@ -1,7 +1,12 @@
 class FoodHuntBasket extends Object2D
 {
-    /** @type {FoodHuntPlayer} */
-    player = null;
+    constructor(name)
+    {
+        super(name);
+
+        /** @type {FoodHuntPlayer} */
+        this.player = null;
+    }
 
     _update( /** @type {Number} */ delta)
     {

+ 21 - 16
src/elements/earth/foodHunt/FoodHuntDialogue.js

@@ -1,23 +1,28 @@
 class FoodHuntDialogue extends Object2D
 {
-    /** @type {String} */
-    text1 = "Você conhece alguma árvore que dá tantos frutos diferentes assim?";
-    /** @type {String} */
-    text2 = " Já ouviu falar na grande árvore do Tamoromu? Converse com sua professora."
+    constructor(name)
+    {
+        super(name);
+        
+        /** @type {String} */
+        this.text1 = "Você conhece alguma árvore que dá tantos frutos diferentes assim?";
+        /** @type {String} */
+        this.text2 = " Já ouviu falar na grande árvore do Tamoromu? Converse com sua professora."
 
-    /** @type {Number} */
-    bgOpacity = 0;
-    /** @type {Number} */
-    text1Opacity = 0;
-    /** @type {Number} */
-    text2Opacity = 0;
+        /** @type {Number} */
+        this.bgOpacity = 0;
+        /** @type {Number} */
+        this.text1Opacity = 0;
+        /** @type {Number} */
+        this.text2Opacity = 0;
 
-    /** @type {Button} */
-    continueButton = null;
-    /** @type {Tween} */
-    tween = null;
-    /** @type {Timer} */
-    buttonTimer = null;
+        /** @type {Button} */
+        this.continueButton = null;
+        /** @type {Tween} */
+        this.tween = null;
+        /** @type {Timer} */
+        this.buttonTimer = null;
+    }
 
     _initSignals()
     {

+ 18 - 13
src/elements/earth/foodHunt/FoodHuntFruit.js

@@ -1,18 +1,23 @@
 class FoodHuntFruit extends Object2D
 {
-    /** @type {Number} */
-    G = 10;
-
-    /** @type {FoodHuntBasket} */
-    basket = null;
-    /** @type {Color} */
-    color = new Color(0, 0, 0);
-    /** @type {Number} */
-    r = 50;
-    /** @type {Number} */
-    fallVel = 0;
-    /** @type {Boolean} */
-    collected = false;
+    constructor(name)
+    {
+        super(name);
+        
+        /** @type {Number} */
+        this.G = 10;
+    
+        /** @type {FoodHuntBasket} */
+        this.basket = null;
+        /** @type {Color} */
+        this.color = new Color(0, 0, 0);
+        /** @type {Number} */
+        this.r = 50;
+        /** @type {Number} */
+        this.fallVel = 0;
+        /** @type {Boolean} */
+        this.collected = false;
+    }
 
     _initSignals()
     {

+ 35 - 30
src/elements/earth/foodHunt/FoodHuntGame.js

@@ -1,35 +1,40 @@
 class FoodHuntGame extends Object2D
 {
-    /** @type {Button} */
-    backButton = null;
-
-    /** @type {FoodHuntPlayer} */
-    player = null;
-    /** @type {FoodHuntTree} */
-    tree = null;
-    /** @type {Object2D} */
-    fruits = null;
-    /** @type {FoodHuntBasket} */
-    basket = null;
-    /** @type {FoodHuntDialogue} */
-    dialogue = null;
-
-    /** @type {Timer} */
-    initialTimer = null;
-    /** @type {Timer} */
-    gameTimer = null;
-    /** @type {Timer} */
-    fruitsTimer = null;
-    /** @type {Timer} */
-    endGameTimer = null;
-
-    /** @type {Boolean} */
-    gameStarted = false;
-    /** @type {Boolean} */
-    gameEnded = false;
-
-    /** @type {Number} */
-    points = 0;
+    constructor(name)
+    {
+        super(name);
+
+        /** @type {Button} */
+        this.backButton = null;
+    
+        /** @type {FoodHuntPlayer} */
+        this.player = null;
+        /** @type {FoodHuntTree} */
+        this.tree = null;
+        /** @type {Object2D} */
+        this.fruits = null;
+        /** @type {FoodHuntBasket} */
+        this.basket = null;
+        /** @type {FoodHuntDialogue} */
+        this.dialogue = null;
+    
+        /** @type {Timer} */
+        this.initialTimer = null;
+        /** @type {Timer} */
+        this.gameTimer = null;
+        /** @type {Timer} */
+        this.fruitsTimer = null;
+        /** @type {Timer} */
+        this.endGameTimer = null;
+    
+        /** @type {Boolean} */
+        this.gameStarted = false;
+        /** @type {Boolean} */
+        this.gameEnded = false;
+    
+        /** @type {Number} */
+        this.points = 0;
+    }
 
     _setup()
     {

+ 7 - 2
src/elements/earth/foodHunt/FoodHuntPlayer.js

@@ -1,7 +1,12 @@
 class FoodHuntPlayer extends Object2D
 {
-    /** @type {Number} */
-    direction = 0;
+    constructor(name)
+    {
+        super(name);
+
+        /** @type {Number} */
+        this.direction = 0;
+    }
 
     _setup()
     {

+ 19 - 14
src/elements/earth/letterHunt/LetterHuntDialogue.js

@@ -1,19 +1,24 @@
 class LetterHuntDialogue extends Object2D
 {
-    /** @type {String} */
-    text = ``;
-
-    /** @type {Number} */
-    bgOpacity = 0;
-    /** @type {Number} */
-    textOpacity = 0;
+    constructor(name)
+    {
+        super(name);
 
-    /** @type {Button} */
-    continueButton = null;
-    /** @type {Tween} */
-    tween = null;
-    /** @type {Timer} */
-    buttonTimer = null;
+        /** @type {String} */
+        this.text = ``;
+    
+        /** @type {Number} */
+        this.bgOpacity = 0;
+        /** @type {Number} */
+        this.textOpacity = 0;
+    
+        /** @type {Button} */
+        this.continueButton = null;
+        /** @type {Tween} */
+        this.tween = null;
+        /** @type {Timer} */
+        this.buttonTimer = null;
+    }
 
     _initSignals()
     {
@@ -43,7 +48,7 @@ class LetterHuntDialogue extends Object2D
 
     _draw( /** @type {number} */ delta, /** @type {p5.Graphics} */ db)
     {
-        this.text = `ACABOU O JOGO!\nVOCÊ GANHOU ${this.parent.points} PONTOS!`;
+        this.text = `ACABOU O JOGO!\n\nVOCÊ GANHOU ${this.parent.points} PONTOS!`;
         db.noStroke();
         db.fill(0, this.bgOpacity);
         db.rectMode(CENTER);

+ 26 - 21
src/elements/earth/letterHunt/LetterHuntGame.js

@@ -1,26 +1,31 @@
 class LetterHuntGame extends Object2D
 {
-    /** @type {Button} */
-    backButton = null;
-    /** @type {Object2D} */
-    plants = null;
-    /** @type {LetterHuntDialogue} */
-    dialogue = null;
-    /** @type {Timer} */
-    initialTimer = null;
-    /** @type {Timer} */
-    roundTimer = null;
-    /** @type {Timer} */
-    gameTimer = null;
-
-    /** @type {Boolean} */
-    gameStarted = false;
-    /** @type {Boolean} */
-    gameEnded = false;
-    /** @type {Number} */
-    points = 0;
-    /** @type {String} */
-    answerLetter = "";
+    constructor(name)
+    {
+        super(name);
+
+        /** @type {Button} */
+        this.backButton = null;
+        /** @type {Object2D} */
+        this.plants = null;
+        /** @type {LetterHuntDialogue} */
+        this.dialogue = null;
+        /** @type {Timer} */
+        this.initialTimer = null;
+        /** @type {Timer} */
+        this.roundTimer = null;
+        /** @type {Timer} */
+        this.gameTimer = null;
+
+        /** @type {Boolean} */
+        this.gameStarted = false;
+        /** @type {Boolean} */
+        this.gameEnded = false;
+        /** @type {Number} */
+        this.points = 0;
+        /** @type {String} */
+        this.answerLetter = "";
+    }
 
     _setup()
     {

+ 20 - 15
src/elements/earth/letterHunt/LetterHuntPlant.js

@@ -1,21 +1,26 @@
 class LetterHuntPlant extends Object2D
 {
-    /** @type {String} */
-    letter = "";
-
-    /** @type {Area2D} */
-    area = null;
-    /** @type {Boolean} */
-    mouseOver = false;
-    /** @type {Boolean} */
-    mosueIsDown = false;
-    /** @type {Boolean} */
-    selected = false;
-    /** @type {Boolean} */
-    selectable = true;
+    constructor(name)
+    {
+        super(name);
 
-    /** @type {Number} */
-    growSpeed = 2;
+        /** @type {String} */
+        this.letter = "";
+    
+        /** @type {Area2D} */
+        this.area = null;
+        /** @type {Boolean} */
+        this.mouseOver = false;
+        /** @type {Boolean} */
+        this.mosueIsDown = false;
+        /** @type {Boolean} */
+        this.selected = false;
+        /** @type {Boolean} */
+        this.selectable = true;
+    
+        /** @type {Number} */
+        this.growSpeed = 2;
+    }
 
     _initSignals()
     {

+ 9 - 4
src/elements/earth/rebus/game/RebusCardVisualEffect.js

@@ -21,10 +21,15 @@
 
 class RebusCardVisualEffect extends Object2D
 {
-    /** @type {number} */
-    glowIterations = 7;
-    /** @type {number} */
-    glowAmount = 0;
+    constructor(name)
+    {
+        super(name);
+
+        /** @type {number} */
+        this.glowIterations = 7;
+        /** @type {number} */
+        this.glowAmount = 0;
+    }
 
     _draw( /** @type {number} */ delta, /** @type {p5.Graphics} */ db)
     {

+ 17 - 12
src/elements/earth/rebus/game/RebusGame.js

@@ -21,19 +21,24 @@
 
 class RebusGame extends Object2D
 {
-    /** @type {Object} */
-    levelData = null;
-    /** @type {Boolean} */
-    gameFinished = false;
-    /** @type {number} */
-    points = 3;
+    constructor(name)
+    {
+        super(name);
 
-    /** @type {Button} */
-    backButton = null;
-    /** @type {Button} */
-    continueButton = null;
-    /** @type {Button} */
-    timer = null;
+        /** @type {Object} */
+        this.levelData = null;
+        /** @type {Boolean} */
+        this.gameFinished = false;
+        /** @type {number} */
+        this.points = 3;
+    
+        /** @type {Button} */
+        this.backButton = null;
+        /** @type {Button} */
+        this.continueButton = null;
+        /** @type {Button} */
+        this.timer = null;
+    }
 
     _setup()
     {

+ 12 - 7
src/elements/earth/rebus/game/RebusGameVisualEffects.js

@@ -21,19 +21,24 @@
 
 class RebusGameVisualEffects extends Object2D
 {
-    /** @type {String} */
-    suffix = "";
-    /** @type {number} */
-    bgOpacity = 0;
-    /** @type {number} */
-    textOpacity = 0;
+    constructor(name)
+    {
+        super(name);
+
+        /** @type {String} */
+        this.suffix = "";
+        /** @type {number} */
+        this.bgOpacity = 0;
+        /** @type {number} */
+        this.textOpacity = 0;
+    }
 
     _draw( /** @type {number} */ delta, /** @type {p5.Graphics} */ db)
     {
         if (this.parent.gameFinished)
         {
             db.noStroke();
-            db.fill(0, min(this.bgOpacity +=  75 * delta, 200));
+            db.fill(0, min(this.bgOpacity += 75 * delta, 200));
             db.rectMode(CENTER);
             db.rect(db.width / 2, db.height / 2, 1800, 600, 40, 40);
             db.textAlign(CENTER, CENTER);

+ 29 - 24
src/elements/earth/rebus/game/RebusOptionCard.js

@@ -21,30 +21,35 @@
 
 class RebusOptionCard extends Object2D
 {
-    /** @type {TextureRes} */
-    thumb = null;
-    /** @type {String} */
-    imgName = "";
-    /** @type {Boolean} */
-    isAnswer = false;
-    /** @type {Boolean} */
-    selected = false;
-    /** @type {Boolean} */
-    selectable = true;
-
-    /** @type {Color} */
-    fillColor = new Color(200, 200, 200);
-    /** @type {Boolean} */
-    mouseOver = false;
-    /** @type  {Boolean} */
-    mousePress = false;
-
-    /** @type {Boolean} */
-    tweenStarted = false;
-    /** @type {Tween} */
-    tween = null;
-    /** @type {Timer} */
-    timer = null;
+    constructor(name)
+    {
+        super(name);
+
+        /** @type {TextureRes} */
+        this.thumb = null;
+        /** @type {String} */
+        this.imgName = "";
+        /** @type {Boolean} */
+        this.isAnswer = false;
+        /** @type {Boolean} */
+        this.selected = false;
+        /** @type {Boolean} */
+        this.selectable = true;
+    
+        /** @type {Color} */
+        this.fillColor = new Color(200, 200, 200);
+        /** @type {Boolean} */
+        this.mouseOver = false;
+        /** @type  {Boolean} */
+        this.mousePress = false;
+    
+        /** @type {Boolean} */
+        this.tweenStarted = false;
+        /** @type {Tween} */
+        this.tween = null;
+        /** @type {Timer} */
+        this.timer = null;
+    }
 
     _initSignals()
     {

+ 13 - 8
src/elements/earth/rebus/game/RebusQuestionCard.js

@@ -21,15 +21,20 @@
 
 class RebusQuestionCard extends Object2D
 {
-    /** @type {TextureRes} */
-    thumb = null;
-    /** @type {String} */
-    imgName = "";
+    constructor(name)
+    {
+        super(name);
 
-    /** @type {Color} */
-    fillColor = new Color(200, 200, 200);
-    /** @type {Tween} */
-    tween = null;
+        /** @type {TextureRes} */
+        this.thumb = null;
+        /** @type {String} */
+        this.imgName = "";
+    
+        /** @type {Color} */
+        this.fillColor = new Color(200, 200, 200);
+        /** @type {Tween} */
+        this.tween = null;
+    }
 
     _setup()
     {

+ 7 - 2
src/elements/earth/rebus/level_selector/RebusLevelButton.js

@@ -21,8 +21,13 @@
 
 class RebusLevelButton extends Button
 {
-    /** @type {Object} */
-    levelData = null;
+    constructor(name)
+    {
+        super(name);
+
+        /** @type {Object} */
+        this.levelData = null;
+    }
 
     _initSignals()
     {

+ 14 - 9
src/elements/earth/rebus/level_selector/RebusLevelSelector.js

@@ -21,16 +21,21 @@
 
 class RebusLevelSelector extends Object2D
 {
-    /** @type {Object} */
-    gridMargins = {
-        left: 0,
-        right: 0,
-        up: 500,
-        down: 0
-    };
+    constructor(name)
+    {
+        super(name);
 
-    /** @type {number} */
-    gridCols = 5;
+        /** @type {Object} */
+        this.gridMargins = {
+            left: 0,
+            right: 0,
+            up: 500,
+            down: 0
+        };
+    
+        /** @type {number} */
+        this.gridCols = 5;
+    }
 
     _setup()
     {

+ 27 - 20
src/elements/earth/rebus/tutorial/RebusTutorial.js

@@ -21,26 +21,33 @@
 
 class RebusTutorial extends Object2D
 {
-    /** @type {Object} */
-    levelData = null;
-    /** @type {Boolean} */
-    gameFinished = false;
-    /** @type {Number} */
-    points = 3;
-
-    /** @type {Button} */
-    backButton = null;
-    continueButton = null;
-    timer = null;
-
-    /** @type {Number} */
-    tutorialStep = 0;
-    /** @type {Array} */
-    questionCards = [];
-    /** @type {Array} */
-    optionCards = [];
-    /** @type {Number} */
-    answerIdx = 0;
+    constructor(name)
+    {
+        super(name);
+
+        /** @type {Object} */
+        this.levelData = null;
+        /** @type {Boolean} */
+        this.gameFinished = false;
+        /** @type {Number} */
+        this.points = 3;
+    
+        /** @type {Button} */
+        this.backButton = null;
+        /** @type {Button} */
+        this.continueButton = null;
+        /** @type {Timer} */
+        this.timer = null;
+    
+        /** @type {Number} */
+        this.tutorialStep = 0;
+        /** @type {Array} */
+        this.questionCards = [];
+        /** @type {Array} */
+        this.optionCards = [];
+        /** @type {Number} */
+        this.answerIdx = 0;
+    }
 
     _setup()
     {

+ 11 - 6
src/elements/earth/rebus/tutorial/RebusTutorialVisualEffects.js

@@ -21,12 +21,17 @@
 
 class RebusTutorialVisualEffects extends Object2D
 {
-    /** @type {String} */
-    text = "";
-    /** @type {Number} */
-    bgOpacity = 0;
-    /** @type {Number} */
-    textOpacity = 0;
+    constructor(name)
+    {
+        super(name);
+
+        /** @type {String} */
+        this.text = "";
+        /** @type {Number} */
+        this.bgOpacity = 0;
+        /** @type {Number} */
+        this.textOpacity = 0;
+    }
 
     _draw( /** @type {number} */ delta, /** @type {p5.Graphics} */ db)
     {