RebusTutorialVisualEffects.js 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /************************************************************************
  2. * RebusTutorialVisualEffects.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 RebusTutorialVisualEffects extends Object2D
  22. {
  23. /** @type {String} */
  24. text = "";
  25. /** @type {Number} */
  26. bgOpacity = 0;
  27. /** @type {Number} */
  28. textOpacity = 0;
  29. _draw( /** @type {number} */ delta, /** @type {p5.Graphics} */ db)
  30. {
  31. switch (this.parent.tutorialStep)
  32. {
  33. case 0:
  34. this.bgOpacity = min(this.bgOpacity + 150 * delta, 200);
  35. this.textOpacity = min(this.bgOpacity + 150 * delta, 255);
  36. this.text = `Vamos ler rébus?\nRébus é uma palavra formada quando juntamos os primeiros\npedacinhos de outras palavras.\nVeja!`;
  37. break;
  38. case 1:
  39. this.bgOpacity = max(this.bgOpacity - 150 * delta, 0);
  40. this.textOpacity = max(this.bgOpacity - 150 * delta, 0);
  41. this.text = `Vamos ler rébus?\nRébus é uma palavra formada quando juntamos os primeiros\npedacinhos de outras palavras.\nVeja!`;
  42. break;
  43. case 2:
  44. this.bgOpacity = 0;
  45. this.textOpacity = 0;
  46. break;
  47. case 3:
  48. this.bgOpacity = min(this.bgOpacity + 150 * delta, 200);
  49. this.textOpacity = min(this.bgOpacity + 150 * delta, 255);
  50. this.text = `Que palavra será formada ao juntarmos o começo dessas duas palavras?`;
  51. break;
  52. case 4:
  53. this.bgOpacity = max(this.bgOpacity - 150 * delta, 0);
  54. this.textOpacity = max(this.bgOpacity - 150 * delta, 0);
  55. this.text = `Que palavra será formada ao juntarmos o começo dessas duas palavras?`;
  56. break;
  57. case 5:
  58. this.bgOpacity = 0;
  59. this.textOpacity = 0;
  60. break;
  61. case 7:
  62. this.bgOpacity = min(this.bgOpacity + 150 * delta, 200);
  63. this.textOpacity = min(this.bgOpacity + 150 * delta, 255);
  64. this.text = `Agora é sua vez!`;
  65. break;
  66. }
  67. db.noStroke();
  68. db.fill(0, this.bgOpacity);
  69. db.rectMode(CENTER);
  70. db.rect(db.width / 2, db.height / 2, 1800, 600, 40, 40);
  71. db.textAlign(CENTER, CENTER);
  72. db.fill(255, this.textOpacity);
  73. db.textSize(40);
  74. db.text(this.text, db.width / 2, db.height / 2 - 100);
  75. }
  76. }