brick-engine-js 1.0.8 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/dist/app.js +1 -4952
  2. package/dist/brick-engine.js +1 -4970
  3. package/dist/css/{app.bundle.css → app.0ce9b8479d1758fc15ba.css} +0 -2
  4. package/dist/css/{brick-engine.bundle.css → brick-engine.0ce9b8479d1758fc15ba.css} +0 -2
  5. package/dist/docs/GAME_DEVELOPER_GUIDE.html +1 -1
  6. package/dist/docs/brick-engine-guide.html +1 -1
  7. package/dist/docs/getting-started.html +1 -1
  8. package/dist/docs/jsdoc_standard.html +1 -1
  9. package/dist/docs/publishing.html +1 -1
  10. package/dist/docs/reference/interfaces/modules/Session.html +1 -1
  11. package/dist/docs/reference/modules/GameMenu.html +1 -1
  12. package/dist/docs/reference/modules/GameSession.html +1 -1
  13. package/dist/docs/reference/modules/InitialStateSnapshot.html +1 -1
  14. package/dist/docs/reference/modules/SessionModal.html +1 -1
  15. package/dist/docs/testing_best_practices.html +1 -1
  16. package/dist/index.html +1 -15
  17. package/dist/vendor/p5.min.js +1 -1
  18. package/package.json +2 -4
  19. package/dist/app.js.map +0 -1
  20. package/dist/brick-engine.js.map +0 -1
  21. package/dist/css/app.bundle.css.map +0 -1
  22. package/dist/css/brick-engine.bundle.css.map +0 -1
  23. package/docs/GAME_DEVELOPER_GUIDE.adoc +0 -167
  24. package/docs/brick-engine-guide.adoc +0 -87
  25. package/docs/diagrams/lifecycle.mmd +0 -19
  26. package/docs/documentation_style_guide.adoc +0 -210
  27. package/docs/getting-started.adoc +0 -147
  28. package/docs/images/lifecycle.svg +0 -1
  29. package/docs/jsdoc_standard.adoc +0 -109
  30. package/docs/publishing.adoc +0 -58
  31. package/docs/reference/enums/Color.adoc +0 -35
  32. package/docs/reference/enums/ControlEventType.adoc +0 -28
  33. package/docs/reference/enums/ControlKey.adoc +0 -34
  34. package/docs/reference/enums/FontAlignment.adoc +0 -43
  35. package/docs/reference/enums/FontSize.adoc +0 -31
  36. package/docs/reference/enums/Sound.adoc +0 -42
  37. package/docs/reference/enums/StateProperty.adoc +0 -33
  38. package/docs/reference/helpers/CellHelper.adoc +0 -37
  39. package/docs/reference/helpers/ControlInputHandlerHelper.adoc +0 -57
  40. package/docs/reference/helpers/CoordinateHelper.adoc +0 -118
  41. package/docs/reference/helpers/RelativeValuesHelper.adoc +0 -53
  42. package/docs/reference/interfaces/Debuggable.adoc +0 -29
  43. package/docs/reference/interfaces/GameModules.adoc +0 -35
  44. package/docs/reference/interfaces/Initializable.adoc +0 -24
  45. package/docs/reference/interfaces/RendererInitializable.adoc +0 -33
  46. package/docs/reference/interfaces/StateSyncable.adoc +0 -41
  47. package/docs/reference/interfaces/modules/Control.adoc +0 -98
  48. package/docs/reference/interfaces/modules/Grid.adoc +0 -411
  49. package/docs/reference/interfaces/modules/Renderer.adoc +0 -34
  50. package/docs/reference/interfaces/modules/RendererComposite.adoc +0 -57
  51. package/docs/reference/interfaces/modules/Score.adoc +0 -107
  52. package/docs/reference/interfaces/modules/Session.adoc +0 -66
  53. package/docs/reference/interfaces/modules/State.adoc +0 -290
  54. package/docs/reference/interfaces/modules/Text.adoc +0 -110
  55. package/docs/reference/interfaces/modules/Time.adoc +0 -119
  56. package/docs/reference/modules/Debugger.adoc +0 -71
  57. package/docs/reference/modules/DisplayRenderer.adoc +0 -55
  58. package/docs/reference/modules/Game.adoc +0 -256
  59. package/docs/reference/modules/GameControl.adoc +0 -139
  60. package/docs/reference/modules/GameGrid.adoc +0 -794
  61. package/docs/reference/modules/GameHudGrid.adoc +0 -38
  62. package/docs/reference/modules/GameMenu.adoc +0 -39
  63. package/docs/reference/modules/GameRenderer.adoc +0 -79
  64. package/docs/reference/modules/GameScore.adoc +0 -138
  65. package/docs/reference/modules/GameSession.adoc +0 -43
  66. package/docs/reference/modules/GameSound.adoc +0 -111
  67. package/docs/reference/modules/GameState.adoc +0 -318
  68. package/docs/reference/modules/GameText.adoc +0 -139
  69. package/docs/reference/modules/GameTime.adoc +0 -141
  70. package/docs/reference/modules/HudRenderer.adoc +0 -56
  71. package/docs/reference/modules/InitialStateSnapshot.adoc +0 -47
  72. package/docs/reference/modules/SessionModal.adoc +0 -34
  73. package/docs/reference/types/Axis.adoc +0 -28
  74. package/docs/reference/types/Cell.adoc +0 -29
  75. package/docs/reference/types/ControlCallback.adoc +0 -23
  76. package/docs/reference/types/Coordinate.adoc +0 -29
  77. package/docs/reference/types/GameEntry.adoc +0 -29
  78. package/docs/reference/types/GameEvent.adoc +0 -29
  79. package/docs/reference/types/Piece.adoc +0 -32
  80. package/docs/reference/types/RendererMetrics.adoc +0 -29
  81. package/docs/reference/types/Vector.adoc +0 -28
  82. package/docs/testing_best_practices.adoc +0 -190
  83. package/public/CNAME +0 -1
  84. package/public/docs/GAME_DEVELOPER_GUIDE.html +0 -727
  85. package/public/docs/brick-engine-guide.html +0 -610
  86. package/public/docs/diagrams/lifecycle.mmd +0 -19
  87. package/public/docs/documentation_style_guide.html +0 -994
  88. package/public/docs/getting-started.html +0 -648
  89. package/public/docs/images/lifecycle.svg +0 -1
  90. package/public/docs/index.html +0 -593
  91. package/public/docs/jsdoc_standard.html +0 -656
  92. package/public/docs/publishing.html +0 -573
  93. package/public/docs/reference/enums/Color.html +0 -533
  94. package/public/docs/reference/enums/ControlEventType.html +0 -505
  95. package/public/docs/reference/enums/ControlKey.html +0 -529
  96. package/public/docs/reference/enums/FontAlignment.html +0 -545
  97. package/public/docs/reference/enums/FontSize.html +0 -517
  98. package/public/docs/reference/enums/Sound.html +0 -558
  99. package/public/docs/reference/enums/StateProperty.html +0 -525
  100. package/public/docs/reference/helpers/CellHelper.html +0 -520
  101. package/public/docs/reference/helpers/ControlInputHandlerHelper.html +0 -569
  102. package/public/docs/reference/helpers/CoordinateHelper.html +0 -703
  103. package/public/docs/reference/helpers/RelativeValuesHelper.html +0 -560
  104. package/public/docs/reference/interfaces/Debuggable.html +0 -501
  105. package/public/docs/reference/interfaces/GameModules.html +0 -544
  106. package/public/docs/reference/interfaces/Initializable.html +0 -495
  107. package/public/docs/reference/interfaces/RendererInitializable.html +0 -517
  108. package/public/docs/reference/interfaces/StateSyncable.html +0 -542
  109. package/public/docs/reference/interfaces/modules/Control.html +0 -648
  110. package/public/docs/reference/interfaces/modules/Grid.html +0 -1256
  111. package/public/docs/reference/interfaces/modules/Renderer.html +0 -522
  112. package/public/docs/reference/interfaces/modules/RendererComposite.html +0 -577
  113. package/public/docs/reference/interfaces/modules/Score.html +0 -669
  114. package/public/docs/reference/interfaces/modules/Session.html +0 -585
  115. package/public/docs/reference/interfaces/modules/State.html +0 -897
  116. package/public/docs/reference/interfaces/modules/Text.html +0 -668
  117. package/public/docs/reference/interfaces/modules/Time.html +0 -684
  118. package/public/docs/reference/modules/Debugger.html +0 -579
  119. package/public/docs/reference/modules/DisplayRenderer.html +0 -557
  120. package/public/docs/reference/modules/Game.html +0 -909
  121. package/public/docs/reference/modules/GameControl.html +0 -716
  122. package/public/docs/reference/modules/GameGrid.html +0 -1910
  123. package/public/docs/reference/modules/GameHudGrid.html +0 -508
  124. package/public/docs/reference/modules/GameMenu.html +0 -538
  125. package/public/docs/reference/modules/GameRenderer.html +0 -589
  126. package/public/docs/reference/modules/GameScore.html +0 -664
  127. package/public/docs/reference/modules/GameSession.html +0 -533
  128. package/public/docs/reference/modules/GameSound.html +0 -636
  129. package/public/docs/reference/modules/GameState.html +0 -922
  130. package/public/docs/reference/modules/GameText.html +0 -701
  131. package/public/docs/reference/modules/GameTime.html +0 -696
  132. package/public/docs/reference/modules/HudRenderer.html +0 -568
  133. package/public/docs/reference/modules/InitialStateSnapshot.html +0 -557
  134. package/public/docs/reference/modules/SessionModal.html +0 -520
  135. package/public/docs/reference/types/Axis.html +0 -505
  136. package/public/docs/reference/types/Cell.html +0 -514
  137. package/public/docs/reference/types/ControlCallback.html +0 -488
  138. package/public/docs/reference/types/Coordinate.html +0 -510
  139. package/public/docs/reference/types/GameEntry.html +0 -514
  140. package/public/docs/reference/types/GameEvent.html +0 -514
  141. package/public/docs/reference/types/Piece.html +0 -506
  142. package/public/docs/reference/types/RendererMetrics.html +0 -514
  143. package/public/docs/reference/types/Vector.html +0 -509
  144. package/public/docs/testing_best_practices.html +0 -770
  145. package/public/favicon.ico +0 -0
  146. package/public/fonts/digital-7.monoitalic.ttf +0 -0
  147. package/public/images/cell.svg +0 -32
  148. package/public/images/close.png +0 -0
  149. package/public/images/games.png +0 -0
  150. package/public/images/github.png +0 -0
  151. package/public/images/letter-a.png +0 -0
  152. package/public/images/letter-d.png +0 -0
  153. package/public/images/letter-j.png +0 -0
  154. package/public/images/letter-s.png +0 -0
  155. package/public/images/letter-w.png +0 -0
  156. package/public/images/meta-image.png +0 -0
  157. package/public/images/number-1.png +0 -0
  158. package/public/images/number-2.png +0 -0
  159. package/public/images/number-3.png +0 -0
  160. package/public/images/number-4.png +0 -0
  161. package/public/images/number-5.png +0 -0
  162. package/public/images/number-6.png +0 -0
  163. package/public/images/splash.gif +0 -0
  164. package/public/index.html +0 -15
  165. package/public/sounds/sound_00.wav +0 -0
  166. package/public/sounds/sound_01.wav +0 -0
  167. package/public/sounds/sound_02.wav +0 -0
  168. package/public/sounds/sound_03.wav +0 -0
  169. package/public/sounds/sound_04.wav +0 -0
  170. package/public/sounds/sound_05.wav +0 -0
  171. package/public/sounds/sound_06.wav +0 -0
  172. package/public/sounds/sound_07.wav +0 -0
  173. package/public/sounds/sound_08.wav +0 -0
  174. package/public/sounds/sound_09.wav +0 -0
  175. package/public/sounds/sound_10.wav +0 -0
  176. package/public/sounds/sound_11.wav +0 -0
  177. package/public/sounds/sound_12.wav +0 -0
  178. package/public/sounds/sound_13.wav +0 -0
  179. package/public/sounds/sound_14.wav +0 -0
  180. package/public/sounds/sound_15.wav +0 -0
  181. package/public/style/body.css +0 -86
  182. package/public/style/buttons.css +0 -233
  183. package/public/style/debugger.css +0 -117
  184. package/public/style/sessionModal.css +0 -155
  185. package/public/style/sourceCodeAndCommands.css +0 -74
  186. package/public/style/splash.css +0 -13
  187. package/public/style/theme.css +0 -137
  188. /package/dist/{bootstrap.d.ts → types/bootstrap.d.ts} +0 -0
  189. /package/dist/{bootstrap.test.d.ts → types/bootstrap.test.d.ts} +0 -0
  190. /package/dist/{config → types/config}/configs.d.ts +0 -0
  191. /package/dist/{config → types/config}/configs.test.d.ts +0 -0
  192. /package/dist/{core → types/core}/Game.d.ts +0 -0
  193. /package/dist/{core → types/core}/Game.test.d.ts +0 -0
  194. /package/dist/{core → types/core}/InitialStateSnapshot.d.ts +0 -0
  195. /package/dist/{core → types/core}/InitialStateSnapshot.test.d.ts +0 -0
  196. /package/dist/{core → types/core}/helpers/CellHelper.d.ts +0 -0
  197. /package/dist/{core → types/core}/helpers/CellHelper.test.d.ts +0 -0
  198. /package/dist/{core → types/core}/helpers/ControlInputHandlerHelper.d.ts +0 -0
  199. /package/dist/{core → types/core}/helpers/ControlInputHandlerHelper.test.d.ts +0 -0
  200. /package/dist/{core → types/core}/helpers/CoordinateHelper.d.ts +0 -0
  201. /package/dist/{core → types/core}/helpers/CoordinateHelper.test.d.ts +0 -0
  202. /package/dist/{core → types/core}/helpers/InterfaceIdentifierHelper.d.ts +0 -0
  203. /package/dist/{core → types/core}/helpers/InterfaceIdentifierHelper.test.d.ts +0 -0
  204. /package/dist/{core → types/core}/helpers/RelativeValuesHelper.d.ts +0 -0
  205. /package/dist/{core → types/core}/helpers/RelativeValuesHelper.test.d.ts +0 -0
  206. /package/dist/{core → types/core}/module/control/GameControl.d.ts +0 -0
  207. /package/dist/{core → types/core}/module/control/GameControl.test.d.ts +0 -0
  208. /package/dist/{core → types/core}/module/control/GameControlKeyBinding.d.ts +0 -0
  209. /package/dist/{core → types/core}/module/control/GameControlKeyBinding.test.d.ts +0 -0
  210. /package/dist/{core → types/core}/module/grid/GameGrid.d.ts +0 -0
  211. /package/dist/{core → types/core}/module/grid/GameGrid.test.d.ts +0 -0
  212. /package/dist/{core → types/core}/module/grid/GameHudGrid.d.ts +0 -0
  213. /package/dist/{core → types/core}/module/grid/GameHudGrid.test.d.ts +0 -0
  214. /package/dist/{core → types/core}/module/grid/engines/GridAnalysisEngine.d.ts +0 -0
  215. /package/dist/{core → types/core}/module/grid/engines/GridAnalysisEngine.test.d.ts +0 -0
  216. /package/dist/{core → types/core}/module/grid/engines/GridLineEngine.d.ts +0 -0
  217. /package/dist/{core → types/core}/module/grid/engines/GridLineEngine.test.d.ts +0 -0
  218. /package/dist/{core → types/core}/module/grid/engines/GridMovementEngine.d.ts +0 -0
  219. /package/dist/{core → types/core}/module/grid/engines/GridMovementEngine.test.d.ts +0 -0
  220. /package/dist/{core → types/core}/module/grid/engines/GridRegionEngine.d.ts +0 -0
  221. /package/dist/{core → types/core}/module/grid/engines/GridRegionEngine.test.d.ts +0 -0
  222. /package/dist/{core → types/core}/module/grid/engines/GridTransformEngine.d.ts +0 -0
  223. /package/dist/{core → types/core}/module/grid/engines/GridTransformEngine.test.d.ts +0 -0
  224. /package/dist/{core → types/core}/module/renderer/DisplayRenderer.d.ts +0 -0
  225. /package/dist/{core → types/core}/module/renderer/DisplayRenderer.test.d.ts +0 -0
  226. /package/dist/{core → types/core}/module/renderer/GameRenderer.d.ts +0 -0
  227. /package/dist/{core → types/core}/module/renderer/GameRenderer.test.d.ts +0 -0
  228. /package/dist/{core → types/core}/module/renderer/HudRenderer.d.ts +0 -0
  229. /package/dist/{core → types/core}/module/renderer/HudRenderer.test.d.ts +0 -0
  230. /package/dist/{core → types/core}/module/score/GameScore.d.ts +0 -0
  231. /package/dist/{core → types/core}/module/score/GameScore.test.d.ts +0 -0
  232. /package/dist/{core → types/core}/module/session/GameSession.d.ts +0 -0
  233. /package/dist/{core → types/core}/module/session/GameSession.test.d.ts +0 -0
  234. /package/dist/{core → types/core}/module/sound/GameSound.d.ts +0 -0
  235. /package/dist/{core → types/core}/module/sound/GameSound.test.d.ts +0 -0
  236. /package/dist/{core → types/core}/module/state/GameState.d.ts +0 -0
  237. /package/dist/{core → types/core}/module/state/GameState.test.d.ts +0 -0
  238. /package/dist/{core → types/core}/module/text/GameText.d.ts +0 -0
  239. /package/dist/{core → types/core}/module/text/GameText.test.d.ts +0 -0
  240. /package/dist/{core → types/core}/module/time/GameTime.d.ts +0 -0
  241. /package/dist/{core → types/core}/module/time/GameTime.test.d.ts +0 -0
  242. /package/dist/{core → types/core}/types/Interfaces.d.ts +0 -0
  243. /package/dist/{core → types/core}/types/Types.d.ts +0 -0
  244. /package/dist/{core → types/core}/types/enums.d.ts +0 -0
  245. /package/dist/{core → types/core}/types/modules.d.ts +0 -0
  246. /package/dist/{index.d.ts → types/index.d.ts} +0 -0
  247. /package/dist/{main.d.ts → types/main.d.ts} +0 -0
  248. /package/dist/{menu → types/menu}/GameMenu.d.ts +0 -0
  249. /package/dist/{menu → types/menu}/GameMenu.test.d.ts +0 -0
  250. /package/dist/{menu → types/menu}/GameMenuSingleton.d.ts +0 -0
  251. /package/dist/{menu → types/menu}/GameMenuSingleton.test.d.ts +0 -0
  252. /package/dist/{menu → types/menu}/GameRepository.d.ts +0 -0
  253. /package/dist/{menu → types/menu}/GameRepository.test.d.ts +0 -0
  254. /package/dist/{menu → types/menu}/manager/GameManager.d.ts +0 -0
  255. /package/dist/{menu → types/menu}/manager/GameManager.test.d.ts +0 -0
  256. /package/dist/types/{interfaces.d.ts → types/interfaces.d.ts} +0 -0
  257. /package/dist/{view → types/view}/Debugger.d.ts +0 -0
  258. /package/dist/{view → types/view}/Debugger.test.d.ts +0 -0
  259. /package/dist/{view → types/view}/GameView.d.ts +0 -0
  260. /package/dist/{view → types/view}/GameView.test.d.ts +0 -0
  261. /package/dist/{view → types/view}/SessionModal.d.ts +0 -0
  262. /package/dist/{view → types/view}/SessionModal.test.d.ts +0 -0
  263. /package/dist/{view → types/view}/components/layout/ButtonLayout.d.ts +0 -0
  264. /package/dist/{view → types/view}/components/layout/ButtonLayout.test.d.ts +0 -0
  265. /package/dist/{view → types/view}/components/layout/ContainerLayout.d.ts +0 -0
  266. /package/dist/{view → types/view}/components/layout/ContainerLayout.test.d.ts +0 -0
  267. /package/dist/{view → types/view}/components/layout/FrameLayout.d.ts +0 -0
  268. /package/dist/{view → types/view}/components/layout/FrameLayout.test.d.ts +0 -0
  269. /package/dist/{view → types/view}/components/ui/BigButton.d.ts +0 -0
  270. /package/dist/{view → types/view}/components/ui/BigButton.test.d.ts +0 -0
  271. /package/dist/{view → types/view}/components/ui/Button.d.ts +0 -0
  272. /package/dist/{view → types/view}/components/ui/Button.test.d.ts +0 -0
  273. /package/dist/{view → types/view}/components/ui/Canvas.d.ts +0 -0
  274. /package/dist/{view → types/view}/components/ui/Canvas.test.d.ts +0 -0
  275. /package/dist/{view → types/view}/components/ui/SmallButton.d.ts +0 -0
  276. /package/dist/{view → types/view}/components/ui/SmallButton.test.d.ts +0 -0
  277. /package/dist/{view → types/view}/theme/applyColors.d.ts +0 -0
  278. /package/dist/{view → types/view}/theme/applyColors.test.d.ts +0 -0
  279. /package/dist/{view → types/view}/theme/dimensions.d.ts +0 -0
  280. /package/dist/{view → types/view}/theme/dimensions.test.d.ts +0 -0
@@ -1,256 +0,0 @@
1
- = Game Class Reference
2
- :description: The heart of the application, managing the game loop and orchestration of modules.
3
- :keywords: core, game-loop, architecture, orchestration
4
- :toc: left
5
- :toclevels: 3
6
- :sectnums:
7
- :sectlinks:
8
- :icons: font
9
- :source-highlighter: highlight.js
10
- :reproducible:
11
- :experimental:
12
- :idprefix:
13
- :idseparator: -
14
-
15
- The `Game` class is the heart of your application. It manages the game loop (ticks and frames), initialization of core modules, session restoration, and integration with P5.js. All games must extend this class.
16
-
17
- == Properties
18
-
19
- [cols="1,1,2"]
20
- |===
21
- |Property |Type |Description
22
- |`gameId` |`string` |Unique identifier for the specific game implementation. Used as a namespace for local storage and other session-specific requirements logic.
23
- |`modules` |`xref:../interfaces/GameModules.adoc[GameModules]` |Access to all engine modules (grid, control, state, etc.).
24
- |===
25
-
26
- == API Reference
27
-
28
-
29
- '''
30
-
31
- === `addSerializable(serializable: Serializable): void`
32
-
33
- Registers a custom object or module for session persistence.
34
-
35
- **Parameters**
36
-
37
- [cols="1,1,3"]
38
- |===
39
- |Name |Type |Description
40
- |`serializable` |`xref:../interfaces/Serializable.adoc[Serializable]` |The custom object to be saved in the active session.
41
- |===
42
-
43
- **Behavior**
44
-
45
- This method serves to add new custom serializables of the game being developed. This allows the game to save custom properties (like specific player power-ups or puzzle progress) in the browser session. These properties can be automatically restored if the user leaves and returns, continuing the game from the `PLAYING` state. Note that engine modules implementing `Serializable` are automatically detected and added.
46
-
47
-
48
- '''
49
-
50
- === `update(deltaTime: number): void`
51
-
52
- Abstract method for processing game logic.
53
-
54
- **Parameters**
55
-
56
- [cols="1,1,3"]
57
- |===
58
- |Name |Type |Description
59
- |`deltaTime` |`number` |Time elapsed since the last tick (in milliseconds).
60
- |===
61
-
62
- '''
63
-
64
- === `setSwitchHandler(handler: (newGame: Game) => void): void`
65
-
66
- Registers the callback to be used when a game requests to switch to another game.
67
-
68
- **Parameters**
69
-
70
- [cols="1,1,3"]
71
- |===
72
- |`handler` |`Function` |The callback function receiving the target `xref:../modules/Game.adoc[Game]` instance.
73
- |===
74
-
75
- **Behavior**
76
-
77
- This method is used by the engine orchestrator (typically in `main.ts`) to define how game switches should be handled (e.g., re-binding controls, resetting the debugger). It allows the `Game` class to remain decoupled from the specific implementation of the menu or other games.
78
-
79
- '''
80
-
81
- === `propagateSwitchHandler(game: Game): void`
82
-
83
- Copies the active switch handler from one game instance to another.
84
-
85
- **Parameters**
86
-
87
- [cols="1,1,3"]
88
- |===
89
- |Name |Type |Description
90
- |`game` |`xref:../modules/Game.adoc[Game]` |The source game instance providing the handler.
91
- |===
92
-
93
- **Behavior**
94
-
95
- Ensures continuity of the orchestration logic during a switch. When a new game is instantiated and about to become active, this method is called to pass the `_switchHandler` from the current `activeGame` to the new one.
96
-
97
- '''
98
-
99
- === `update(deltaTime: number): void`
100
-
101
- Abstract method for processing game logic.
102
-
103
- **Parameters**
104
-
105
- [cols="1,1,3"]
106
- |===
107
- |Name |Type |Description
108
- |`deltaTime` |`number` |Time elapsed since the last tick (in milliseconds).
109
- |===
110
-
111
- **Behavior**
112
-
113
- Called by the engine on every game logic tick, but **only** when the game state is `playing`. The tick frequency is controlled by `configs.game.tickInterval`.
114
-
115
- **Example**
116
-
117
- [source,typescript]
118
- ----
119
- update(deltaTime: number): void {
120
- const { grid } = this.modules;
121
- grid.shiftRowsDown(1);
122
- }
123
- ----
124
-
125
-
126
- '''
127
-
128
- === `render(): void`
129
-
130
- Abstract method for processing visual frames.
131
-
132
- **Behavior**
133
-
134
- Called by the engine on every render frame (based on browser refresh rate, typically 60fps). Use this for animations, particles, or visual effects that do not affect the logical game state.
135
-
136
- **Example**
137
-
138
- [source,typescript]
139
- ----
140
- render(): void {
141
- // Logic for smooth animations
142
- }
143
- ----
144
-
145
-
146
- '''
147
-
148
- === `setupGame(): void`
149
-
150
- Abstract method for setting up the specific game instance.
151
-
152
- **Behavior**
153
-
154
- Called once after all engine modules are initialized and linked. Use this to set initial player state, subscribe to custom controls, or prepare level data.
155
-
156
- **Example**
157
-
158
- [source,typescript]
159
- ----
160
- setupGame(): void {
161
- this.modules.text.setTextSize(FontSize.MEDIUM);
162
- }
163
- ----
164
-
165
-
166
- '''
167
-
168
-
169
-
170
- === `drawTitleScreen(): void`
171
-
172
- Abstract method for rendering the game's welcome screen.
173
-
174
- **Behavior**
175
-
176
- Called when the engine is powered ON but the game has not yet been started. Executed during the main draw loop instead of `update` and `render`.
177
-
178
-
179
- '''
180
-
181
- === `drawGameOverScreen(): void`
182
-
183
- Abstract method for rendering the screen after a game ends.
184
-
185
- **Behavior**
186
-
187
- Called when the game state is `gameOver`. Executed as the primary rendering logic during Game Over, replacing the standard `render()` call to allow for clean menus or high-score displays.
188
-
189
-
190
- '''
191
-
192
- === `switchGame(newGame: Game): void`
193
-
194
- Switches execution to a new game instance.
195
-
196
- **Parameters**
197
-
198
- [cols="1,1,3"]
199
- |===
200
- |Name |Type |Description
201
- |`newGame` |`Game` |The instance of the new game class to load.
202
- |===
203
-
204
- **Behavior**
205
-
206
- Destroys the current game instance (cleaning up listeners and stopping sound) and passes the new instance to the registered `_switchHandler`. This is the core mechanism for moving between different games or menus.
207
-
208
- > [!NOTE]
209
- > The switch handler must be set or propagated before calling this method, otherwise an error will be logged.
210
-
211
- **Example**
212
-
213
- [source,typescript]
214
- ----
215
- this.switchGame(new MyOtherGame(this.p, this.view));
216
- ----
217
-
218
-
219
- '''
220
-
221
- === `destroy(): void`
222
-
223
- Cleans up the game instance.
224
-
225
- **Behavior**
226
-
227
- Stops the P5.js loop, unbinds all control event listeners, and stops all playing sounds. Use this before disposing of a game instance to prevent memory leaks.
228
-
229
- == Session Management
230
-
231
- The `Game` base class automatically orchestrates gameplay sessions by subscribing to system-level `xref:GameState.adoc[GameState]` events:
232
-
233
- * **Restoring Sessions**: When the state changes to `PLAYING`, the `Game` checks if there are any active sessions stored for its registered `Serializable` instances. If an active session is detected, it triggers a UI modal asking the user if they wish to resume their previous session.
234
- * **Clearing Sessions**: The active session is automatically wiped when the state changes to `GAME_OVER`, ensuring that players do not resume a lost game.
235
-
236
- == Client State Snapshot (Reset)
237
-
238
- To provide a seamless developer experience, the `Game` class implements an internal mechanism to transparently cache and restore custom client properties.
239
-
240
- When a game is instantiated and its `setupGame()` method is invoked, the base `Game` orchestrates a capture of the client's custom properties using the `xref:InitialStateSnapshot.adoc[InitialStateSnapshot]` utility. This ensures that any attributes added by the developer (e.g., player lives, custom counters) are saved in memory without requiring manual implementation.
241
-
242
- When the user triggers a **RESET** action, the `Game` class automatically uses this internal snapshot to restore the custom properties back to their original values, eliminating the need for developers to manually reset their own state variables.
243
-
244
- == Automated System Controls
245
-
246
- The `Game` base class automatically registers listeners for system-level buttons:
247
-
248
- * **POWER**: Toggles engine state.
249
- * **SOUND**: Toggles master mute.
250
- * **COLOR**: Toggles theme color mode.
251
- * **RESET**: Resets the grid, score, clears the active session, and resets the game state.
252
- * **START_PAUSE**: Manages the game lifecycle:
253
- ** Starts the game from the Title Screen.
254
- ** Toggles pause during gameplay.
255
- ** Restarts the game immediately if in a Game Over state (via `resetGameOver`), and clears the active session.
256
- * **EXIT**: Clears the active session and performs a hard stop of the draw loop. In server mode, the orchestrator typically uses the switch handler to return to the `GameMenu`.
@@ -1,139 +0,0 @@
1
- = GameControl Module Reference
2
- :description: Handles user input from physical keyboards and virtual buttons.
3
- :keywords: input, control, keyboard, interaction
4
- :toc: left
5
- :toclevels: 3
6
- :sectnums:
7
- :sectlinks:
8
- :icons: font
9
- :source-highlighter: highlight.js
10
- :reproducible:
11
- :experimental:
12
- :idprefix:
13
- :idseparator: -
14
-
15
- The `GameControl` module handles user input from physical keyboards and virtual buttons. It provides an event-based system for reacting to player actions.
16
-
17
- == Supported Keys (`ControlKey`)
18
-
19
- The engine maps physical keys to virtual engine keys:
20
-
21
- * `xref:../enums/ControlKey.adoc[UP]` / `xref:../enums/ControlKey.adoc[DOWN]` / `xref:../enums/ControlKey.adoc[LEFT]` / `xref:../enums/ControlKey.adoc[RIGHT]`: Directional controls.
22
- * `xref:../enums/ControlKey.adoc[ACTION]`: Primary action button.
23
- * `xref:../enums/ControlKey.adoc[START_PAUSE]`: Toggles game start/pause.
24
- * `xref:../enums/ControlKey.adoc[RESET]`: Soft reset of the game session.
25
- * `xref:../enums/ControlKey.adoc[SOUND]`: Toggles master audio mute.
26
- * `xref:../enums/ControlKey.adoc[COLOR]`: Toggles theme color mode.
27
- * `xref:../enums/ControlKey.adoc[POWER]`: Main engine power toggle.
28
- * `xref:../enums/ControlKey.adoc[EXIT]`: Hard stop of the engine.
29
-
30
- == API Reference
31
-
32
- === `subscribe(key: ControlKey, type: ControlEventType, callback: ControlCallback): void`
33
-
34
- Registers a callback for a specific input event.
35
-
36
- **Parameters**
37
-
38
- [cols="1,1,3"]
39
- |===
40
- |Name |Type |Description
41
- |`key` |`xref:../enums/ControlKey.adoc[ControlKey]` |The virtual key to monitor (e.g., `ControlKey.ACTION`).
42
- |`type` |`xref:../enums/ControlEventType.adoc[ControlEventType]` |The type of trigger (`PRESSED` or `HELD`).
43
- |`callback` |`xref:../types/ControlCallback.adoc[ControlCallback]` |The function to execute when the event occurs.
44
- |===
45
-
46
- **Behavior**
47
-
48
- Adds the callback to the internal subscription list. Multiple callbacks can be registered for the same key/type combination.
49
-
50
- **Example**
51
-
52
- [source,typescript]
53
- ----
54
- control.subscribe(ControlKey.ACTION, ControlEventType.PRESSED, (event) => {
55
- console.log('Action button pressed!');
56
- });
57
- ----
58
-
59
-
60
- '''
61
-
62
- === `unsubscribe(key: ControlKey, type: ControlEventType, callback: ControlCallback): void`
63
-
64
- Removes an existing subscription.
65
-
66
- **Parameters**
67
-
68
- [cols="1,1,3"]
69
- |===
70
- |Name |Type |Description
71
- |`key` |`xref:../enums/ControlKey.adoc[ControlKey]` |The virtual key.
72
- |`type` |`xref:../enums/ControlEventType.adoc[ControlEventType]` |The trigger type.
73
- |`callback` |`xref:../types/ControlCallback.adoc[ControlCallback]` |The reference to the function to remove.
74
- |===
75
-
76
- **Behavior**
77
-
78
- Removes the specified callback from the list. If the callback is not found, the operation does nothing.
79
-
80
-
81
- '''
82
-
83
- === `bindControls(): void`
84
-
85
- Attaches low-level event listeners to the environment.
86
-
87
- **Behavior**
88
-
89
- Enables keyboard and button listeners. This is called automatically by the engine during setup.
90
-
91
-
92
- '''
93
-
94
- === `unbindControls(): void`
95
-
96
- Detaches all input listeners and clears subscriptions.
97
-
98
- **Behavior**
99
-
100
- Removes all low-level event listeners and wipes the internal subscription map. Called automatically during engine destruction.
101
-
102
-
103
- '''
104
-
105
- === `notify(key: ControlKey, type: ControlEventType): void`
106
-
107
- Manually triggers an input event.
108
-
109
- **Parameters**
110
-
111
- [cols="1,1,3"]
112
- |===
113
- |Name |Type |Description
114
- |`key` |`xref:../enums/ControlKey.adoc[ControlKey]` |The key to notify.
115
- |`type` |`xref:../enums/ControlEventType.adoc[ControlEventType]` |The trigger type to simulate.
116
- |===
117
-
118
- **Behavior**
119
-
120
- Executes all callbacks associated with the given key and event type, subject to the following state-based rules:
121
-
122
- * **System Off (`isOff()`)**: Only the `xref:../enums/ControlKey.adoc[POWER]` key is processed. All other keys are ignored.
123
- * **Active States (`!isStarted() || isPlaying() || isGameOver()`)**: All keys are processed normally.
124
- * **Paused State (`isPaused()`)**: Only system keys (e.g., `START_PAUSE`, `SOUND`, `COLOR`, `RESET`, `EXIT`) are processed. Gameplay keys are ignored.
125
-
126
- *Throws an error* if the game modules have not been initialized. It is primarily used internally by the input handler but can be used for automated testing or input simulation.
127
-
128
-
129
- '''
130
-
131
- === `getDebugData(): Record<string, string | number | boolean>`
132
-
133
- Returns metadata for the real-time debugger.
134
-
135
- **Returns**
136
-
137
- `Record<string, string | number | boolean>` - Object containing the number of `total_subscribers` and `tracked_keys`.
138
-
139
-