Valise1TutorialDialogue.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /************************************************************************
  2. * Valise1TutorialDialogue.js
  3. ************************************************************************
  4. * Copyright (c) 2021 Pedro Tonini Rosenberg Schneider.
  5. *
  6. * This file is part of Alfabetiza.
  7. *
  8. * Alfabetiza is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * Alfabetiza is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with Alfabetiza. If not, see <https://www.gnu.org/licenses/>.
  20. *************************************************************************/
  21. class Valise1TutorialDialogue extends Object2D
  22. {
  23. constructor(name)
  24. {
  25. super(name);
  26. /** @type {Button} */
  27. this.continueButton = null;
  28. /** @type {Timer} */
  29. this.timer;
  30. /** @type {String} */
  31. this.text = "";
  32. /** @type {number} */
  33. this.bgOpacity = 0;
  34. /** @type {number} */
  35. this.textOpacity = 0;
  36. }
  37. _initSignals()
  38. {
  39. this.addSignal("continue");
  40. }
  41. _setup()
  42. {
  43. this.continueButton = new Button("ContinueButton", "Continuar");
  44. this.continueButton.connect("mouseClicked", this, "_onContinueButtonMouseClicked");
  45. this.continueButton.hide();
  46. this.continueButton.setFontSize(40);
  47. this.continueButton.setPosition(1920 / 2 - this.continueButton.getSize().x / 2, 600);
  48. this.addChild(this.continueButton);
  49. }
  50. _draw( /** @type {number} */ delta, /** @type {p5.Graphics} */ db)
  51. {
  52. switch (this.parent.tutorialStep)
  53. {
  54. case 0:
  55. this.bgOpacity = 0;
  56. this.textOpacity = 0;
  57. break;
  58. case 1:
  59. this.bgOpacity = min(this.bgOpacity + 150 * delta, 200);
  60. this.textOpacity = min(this.textOpacity + 150 * delta, 255);
  61. this.text = "Qual é a palavra escondida em CUTIA?"
  62. if (this.textOpacity == 255) this.continueButton.show();
  63. break;
  64. case 2:
  65. this.continueButton.hide();
  66. this.bgOpacity = max(this.bgOpacity - 150 * delta, 0);
  67. this.textOpacity = max(this.textOpacity - 150 * delta, 0);
  68. this.text = "Qual é a palavra escondida em CUTIA?"
  69. break;
  70. case 3:
  71. this.bgOpacity = 0;
  72. this.textOpacity = 0;
  73. break;
  74. case 9:
  75. this.bgOpacity = min(this.bgOpacity + 150 * delta, 200);
  76. this.textOpacity = min(this.textOpacity + 150 * delta, 255);
  77. this.text = "A palavra escondida em CUTIA é TIA.\n\nAgora é sua vez!"
  78. if (this.textOpacity == 255) this.continueButton.show();
  79. break;
  80. }
  81. db.noStroke();
  82. db.fill(0, this.bgOpacity);
  83. db.rectMode(CENTER);
  84. db.rect(db.width / 2, db.height / 2, 1800, 600, 40, 40);
  85. db.textAlign(CENTER, CENTER);
  86. db.fill(255, this.textOpacity);
  87. db.textSize(40);
  88. db.text(this.text, db.width / 2, db.height / 2 - 100);
  89. }
  90. _onContinueButtonMouseClicked()
  91. {
  92. this.emitSignal("continue");
  93. }
  94. }