EarthMinigameSelector.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. class EarthMinigameSelector extends Object2D
  2. {
  3. /** @type {Button} */
  4. backButton = null;
  5. /** @type {Button} */
  6. foodHuntButton = null;
  7. /** @type {Button} */
  8. letterHuntButton = null;
  9. /** @type {Button} */
  10. acrofonyButton = null;
  11. /** @type {Button} */
  12. valise1Button = null;
  13. /** @type {Button} */
  14. valise2Button = null;
  15. /** @type {Button} */
  16. valise3Button = null;
  17. /** @type {Button} */
  18. rebusButton = null;
  19. /** @type {Button} */
  20. guessButton = null;
  21. _setup()
  22. {
  23. // Create back button
  24. this.backButton = new Button("BackButton");
  25. this.backButton.setLabel("Voltar");
  26. this.backButton.setFontSize(30);
  27. this.backButton.setPosition(20, 20);
  28. this.backButton.setSize(110, 75);
  29. this.backButton.connect("mouseClicked", this, "_onBackClicked");
  30. this.addChild(this.backButton);
  31. // Values for creating the button grid
  32. var buttonSize = new Vector2(1920 / 4.5, 1080 / 4.5);
  33. var buttonsCorner = new Vector2(1920 / 2 - 1920 / 3, 1080 / 2 - 1080 / 3 + 100);
  34. var buttonMargin = new Vector2(50, 50);
  35. var buttonFontSize = 50;
  36. // Create food hunt button
  37. this.foodHuntButton = new Button("FoodHuntButton", "Caça alimentos");
  38. this.foodHuntButton.setFontSize(buttonFontSize);
  39. this.foodHuntButton.setSize(buttonSize.x - buttonMargin.x, buttonSize.y - buttonMargin.y);
  40. this.foodHuntButton.setPosition(buttonsCorner.x + buttonMargin.x / 2, buttonsCorner.y + buttonMargin.y / 2);
  41. this.foodHuntButton.connect("mouseClicked", this, "_onFoodHuntSelected");
  42. this.addChild(this.foodHuntButton);
  43. // Create letter hunt button
  44. this.letterHuntButton = new Button("LetterHuntButton", "Caça letras");
  45. this.letterHuntButton.setFontSize(buttonFontSize);
  46. this.letterHuntButton.setSize(buttonSize.x - buttonMargin.x, buttonSize.y - buttonMargin.y);
  47. this.letterHuntButton.setPosition(buttonsCorner.x + buttonMargin.x / 2 + buttonSize.x, buttonsCorner.y + buttonMargin.y / 2);
  48. this.letterHuntButton.connect("mouseClicked", this, "_onLetterHuntSelected");
  49. this.addChild(this.letterHuntButton);
  50. // Create acrofony button
  51. this.acrofonyButton = new Button("AcrofonyButton", "Acrofonia");
  52. this.acrofonyButton.setFontSize(buttonFontSize);
  53. this.acrofonyButton.setSize(buttonSize.x - buttonMargin.x, buttonSize.y - buttonMargin.y);
  54. this.acrofonyButton.setPosition(buttonsCorner.x + buttonMargin.x / 2 + 2 * buttonSize.x, buttonsCorner.y + buttonMargin.y / 2);
  55. this.acrofonyButton.connect("mouseClicked", this, "_onAcrofonySelected");
  56. this.addChild(this.acrofonyButton);
  57. // Create valise 1 button
  58. this.valise1Button = new Button("Valise1Button", "Palavra valise 1");
  59. this.valise1Button.setFontSize(buttonFontSize);
  60. this.valise1Button.setSize(buttonSize.x - buttonMargin.x, buttonSize.y - buttonMargin.y);
  61. this.valise1Button.setPosition(buttonsCorner.x + buttonMargin.x / 2, buttonsCorner.y + buttonMargin.y / 2 + buttonSize.y);
  62. this.valise1Button.connect("mouseClicked", this, "_onValise1Selected");
  63. this.addChild(this.valise1Button);
  64. // Create valise 2 button
  65. this.valise2Button = new Button("Valise2Button", "Palavra valise 2");
  66. this.valise2Button.setFontSize(buttonFontSize);
  67. this.valise2Button.setSize(buttonSize.x - buttonMargin.x, buttonSize.y - buttonMargin.y);
  68. this.valise2Button.setPosition(buttonsCorner.x + buttonMargin.x / 2 + buttonSize.x, buttonsCorner.y + buttonMargin.y / 2 + buttonSize.y);
  69. this.valise2Button.connect("mouseClicked", this, "_onValise2Selected");
  70. this.addChild(this.valise2Button);
  71. // Create valise 3 button
  72. this.valise3Button = new Button("Valise3Button", "Palavra valise 3");
  73. this.valise3Button.setFontSize(buttonFontSize);
  74. this.valise3Button.setSize(buttonSize.x - buttonMargin.x, buttonSize.y - buttonMargin.y);
  75. this.valise3Button.setPosition(buttonsCorner.x + buttonMargin.x / 2 + 2 * buttonSize.x, buttonsCorner.y + buttonMargin.y / 2 + buttonSize.y);
  76. this.valise3Button.connect("mouseClicked", this, "_onValise3Selected");
  77. this.addChild(this.valise3Button);
  78. // Create rébus button
  79. this.rebusButton = new Button("RebusButton", "Rébus");
  80. this.rebusButton.setFontSize(buttonFontSize);
  81. this.rebusButton.setSize(buttonSize.x - buttonMargin.x, buttonSize.y - buttonMargin.y);
  82. this.rebusButton.setPosition(buttonsCorner.x + buttonMargin.x / 2 + buttonSize.x / 2, buttonsCorner.y + buttonMargin.y / 2 + 2 * buttonSize.y);
  83. this.rebusButton.connect("mouseClicked", this, "_onRebusSelected");
  84. this.addChild(this.rebusButton);
  85. // Create guess button
  86. this.guessButton = new Button("GuessButton", "Advinha");
  87. this.guessButton.setFontSize(buttonFontSize);
  88. this.guessButton.setSize(buttonSize.x - buttonMargin.x, buttonSize.y - buttonMargin.y);
  89. this.guessButton.setPosition(buttonsCorner.x + buttonMargin.x / 2 + 3 * buttonSize.x / 2, buttonsCorner.y + buttonMargin.y / 2 + 2 * buttonSize.y);
  90. this.guessButton.connect("mouseClicked", this, "_onGuessSelected");
  91. this.addChild(this.guessButton);
  92. }
  93. _draw( /** @type {number} */ delta, /** @type {p5.Graphics} */ db)
  94. {
  95. background(52);
  96. db.textAlign(CENTER, CENTER);
  97. db.fill(255);
  98. db.textSize(100);
  99. db.text("TERRA", 1920 / 2, 125);
  100. db.textSize(40);
  101. db.text("Escolha o mini-jogo", 1920 / 2, 200);
  102. }
  103. _onBackClicked()
  104. {
  105. var es = new EelementSelector("ElementSelector");
  106. GameHandler.addRootObject(es);
  107. this.queueFree();
  108. }
  109. _onFoodHuntSelected()
  110. {
  111. var fh = new FoodHuntGame("FoodHuntGame");
  112. GameHandler.addRootObject(fh);
  113. this.queueFree();
  114. }
  115. _onLetterHuntSelected()
  116. {
  117. var lh = new LetterHuntGame("LetterHunt");
  118. GameHandler.addRootObject(lh);
  119. this.queueFree();
  120. }
  121. _onAcrofonySelected()
  122. {
  123. console.log("Acrofony has been selected");
  124. }
  125. _onValise1Selected()
  126. {
  127. console.log("Palavra valise 1 has been selected");
  128. }
  129. _onValise2Selected()
  130. {
  131. console.log("Palavra valise 2 has been selected");
  132. }
  133. _onValise3Selected()
  134. {
  135. console.log("Palavra valise 3 has been selected");
  136. }
  137. _onRebusSelected()
  138. {
  139. var rls = new RebusLevelSelector("RebusLevelSelector");
  140. GameHandler.addRootObject(rls);
  141. this.queueFree();
  142. }
  143. _onGuessSelected()
  144. {
  145. console.log("Guess has been selected");
  146. }
  147. }