RebusGameVisualEffects.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /************************************************************************
  2. * RebusGameVisualEffects.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 RebusGameVisualEffects extends Object2D
  22. {
  23. constructor(name)
  24. {
  25. super(name);
  26. /** @type {String} */
  27. this.suffix = "";
  28. /** @type {number} */
  29. this.bgOpacity = 0;
  30. /** @type {number} */
  31. this.textOpacity = 0;
  32. }
  33. _draw( /** @type {number} */ delta, /** @type {p5.Graphics} */ db)
  34. {
  35. if (this.parent.gameFinished)
  36. {
  37. db.noStroke();
  38. db.fill(0, min(this.bgOpacity += 75 * delta, 200));
  39. db.rectMode(CENTER);
  40. db.rect(db.width / 2, db.height / 2, 1800, 600, 40, 40);
  41. db.textAlign(CENTER, CENTER);
  42. db.fill(255, min(this.textOpacity += 80 * delta, 255));
  43. db.textSize(40);
  44. this.parent.points > 1 ? this.suffix = "S" : this.suffix = "";
  45. db.text(`PARABÉNS, NÍVEL CONCLUÍDO\nVOCÊ GANHOU ${this.parent.points} PONTO${this.suffix}!`, db.width / 2, db.height / 2 - 100);
  46. }
  47. }
  48. }