kiwiengine 0.5.2 → 0.5.3

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 (325) hide show
  1. package/README.ko.md +2 -2
  2. package/README.md +2 -2
  3. package/examples/auto-battle/assets/bgm/battle.mp3 +0 -0
  4. package/examples/auto-battle/assets/bitmap-fonts/white-peaberry.fnt +107 -0
  5. package/examples/auto-battle/assets/bitmap-fonts/white-peaberry.png +0 -0
  6. package/examples/auto-battle/assets/joystick/joystick.png +0 -0
  7. package/examples/auto-battle/assets/joystick/knob.png +0 -0
  8. package/examples/auto-battle/assets/sfx/hero/die/die.wav +0 -0
  9. package/examples/auto-battle/assets/sfx/hero/heal/heal.wav +0 -0
  10. package/examples/auto-battle/assets/sfx/hero/hit/hit1.wav +0 -0
  11. package/examples/auto-battle/assets/sfx/hero/hit/hit2.wav +0 -0
  12. package/examples/auto-battle/assets/sfx/hero/hit/hit3.wav +0 -0
  13. package/examples/auto-battle/assets/sfx/hero/miss/miss1.wav +0 -0
  14. package/examples/auto-battle/assets/sfx/hero/miss/miss2.wav +0 -0
  15. package/examples/auto-battle/assets/sfx/hero/miss/miss3.wav +0 -0
  16. package/examples/auto-battle/assets/sfx/orc/die/die.wav +0 -0
  17. package/examples/auto-battle/assets/sfx/orc/hit/hit1.wav +0 -0
  18. package/examples/auto-battle/assets/sfx/orc/hit/hit2.wav +0 -0
  19. package/examples/auto-battle/assets/sfx/orc/hit/hit3.wav +0 -0
  20. package/examples/auto-battle/assets/sfx/orc/miss/miss1.wav +0 -0
  21. package/examples/auto-battle/assets/sfx/orc/miss/miss2.wav +0 -0
  22. package/examples/auto-battle/assets/sfx/orc/miss/miss3.wav +0 -0
  23. package/examples/auto-battle/assets/spritesheets/hero-atlas.json +246 -0
  24. package/examples/auto-battle/assets/spritesheets/hero.png +0 -0
  25. package/examples/auto-battle/assets/spritesheets/orc-atlas.json +246 -0
  26. package/examples/auto-battle/assets/spritesheets/orc.png +0 -0
  27. package/examples/auto-battle/assets/spritesheets/potion-atlas.json +68 -0
  28. package/examples/auto-battle/assets/spritesheets/potion.png +0 -0
  29. package/examples/auto-battle/dist/game.js +2 -0
  30. package/examples/auto-battle/dist/game.js.LICENSE.txt +35 -0
  31. package/examples/auto-battle/hud/damage-text.ts +46 -0
  32. package/examples/auto-battle/hud/heal-text.ts +46 -0
  33. package/examples/auto-battle/hud/hp-bar.ts +38 -0
  34. package/examples/auto-battle/index.ts +41 -0
  35. package/examples/auto-battle/objects/character.ts +95 -0
  36. package/examples/auto-battle/objects/hero.ts +119 -0
  37. package/examples/auto-battle/objects/orc.ts +107 -0
  38. package/examples/auto-battle/objects/potion.ts +27 -0
  39. package/examples/auto-battle/stage.ts +366 -0
  40. package/examples/battle-benchmark-matterjs/assets/bgm/battle.mp3 +0 -0
  41. package/examples/battle-benchmark-matterjs/assets/bitmap-fonts/white-peaberry.fnt +107 -0
  42. package/examples/battle-benchmark-matterjs/assets/bitmap-fonts/white-peaberry.png +0 -0
  43. package/examples/battle-benchmark-matterjs/assets/joystick/joystick.png +0 -0
  44. package/examples/battle-benchmark-matterjs/assets/joystick/knob.png +0 -0
  45. package/examples/battle-benchmark-matterjs/assets/sfx/hero/die/die.wav +0 -0
  46. package/examples/battle-benchmark-matterjs/assets/sfx/hero/heal/heal.wav +0 -0
  47. package/examples/battle-benchmark-matterjs/assets/sfx/hero/hit/hit1.wav +0 -0
  48. package/examples/battle-benchmark-matterjs/assets/sfx/hero/hit/hit2.wav +0 -0
  49. package/examples/battle-benchmark-matterjs/assets/sfx/hero/hit/hit3.wav +0 -0
  50. package/examples/battle-benchmark-matterjs/assets/sfx/hero/miss/miss1.wav +0 -0
  51. package/examples/battle-benchmark-matterjs/assets/sfx/hero/miss/miss2.wav +0 -0
  52. package/examples/battle-benchmark-matterjs/assets/sfx/hero/miss/miss3.wav +0 -0
  53. package/examples/battle-benchmark-matterjs/assets/sfx/orc/die/die.wav +0 -0
  54. package/examples/battle-benchmark-matterjs/assets/sfx/orc/hit/hit1.wav +0 -0
  55. package/examples/battle-benchmark-matterjs/assets/sfx/orc/hit/hit2.wav +0 -0
  56. package/examples/battle-benchmark-matterjs/assets/sfx/orc/hit/hit3.wav +0 -0
  57. package/examples/battle-benchmark-matterjs/assets/sfx/orc/miss/miss1.wav +0 -0
  58. package/examples/battle-benchmark-matterjs/assets/sfx/orc/miss/miss2.wav +0 -0
  59. package/examples/battle-benchmark-matterjs/assets/sfx/orc/miss/miss3.wav +0 -0
  60. package/examples/battle-benchmark-matterjs/assets/spritesheets/hero-atlas.json +246 -0
  61. package/examples/battle-benchmark-matterjs/assets/spritesheets/hero.png +0 -0
  62. package/examples/battle-benchmark-matterjs/assets/spritesheets/orc-atlas.json +246 -0
  63. package/examples/battle-benchmark-matterjs/assets/spritesheets/orc.png +0 -0
  64. package/examples/battle-benchmark-matterjs/assets/spritesheets/potion-atlas.json +68 -0
  65. package/examples/battle-benchmark-matterjs/assets/spritesheets/potion.png +0 -0
  66. package/examples/battle-benchmark-matterjs/dist/game.js +2 -0
  67. package/examples/battle-benchmark-matterjs/dist/game.js.LICENSE.txt +35 -0
  68. package/examples/battle-benchmark-matterjs/hud/damage-text.ts +46 -0
  69. package/examples/battle-benchmark-matterjs/hud/heal-text.ts +46 -0
  70. package/examples/battle-benchmark-matterjs/hud/hp-bar.ts +38 -0
  71. package/examples/battle-benchmark-matterjs/index.html +24 -0
  72. package/examples/battle-benchmark-matterjs/index.ts +41 -0
  73. package/examples/battle-benchmark-matterjs/objects/character.ts +95 -0
  74. package/examples/battle-benchmark-matterjs/objects/hero.ts +111 -0
  75. package/examples/battle-benchmark-matterjs/objects/orc.ts +107 -0
  76. package/examples/battle-benchmark-matterjs/objects/potion.ts +27 -0
  77. package/examples/battle-benchmark-matterjs/stage.ts +177 -0
  78. package/examples/battle-benchmark-separation/assets/bgm/battle.mp3 +0 -0
  79. package/examples/battle-benchmark-separation/assets/bitmap-fonts/white-peaberry.fnt +107 -0
  80. package/examples/battle-benchmark-separation/assets/bitmap-fonts/white-peaberry.png +0 -0
  81. package/examples/battle-benchmark-separation/assets/joystick/joystick.png +0 -0
  82. package/examples/battle-benchmark-separation/assets/joystick/knob.png +0 -0
  83. package/examples/battle-benchmark-separation/assets/sfx/hero/die/die.wav +0 -0
  84. package/examples/battle-benchmark-separation/assets/sfx/hero/heal/heal.wav +0 -0
  85. package/examples/battle-benchmark-separation/assets/sfx/hero/hit/hit1.wav +0 -0
  86. package/examples/battle-benchmark-separation/assets/sfx/hero/hit/hit2.wav +0 -0
  87. package/examples/battle-benchmark-separation/assets/sfx/hero/hit/hit3.wav +0 -0
  88. package/examples/battle-benchmark-separation/assets/sfx/hero/miss/miss1.wav +0 -0
  89. package/examples/battle-benchmark-separation/assets/sfx/hero/miss/miss2.wav +0 -0
  90. package/examples/battle-benchmark-separation/assets/sfx/hero/miss/miss3.wav +0 -0
  91. package/examples/battle-benchmark-separation/assets/sfx/orc/die/die.wav +0 -0
  92. package/examples/battle-benchmark-separation/assets/sfx/orc/hit/hit1.wav +0 -0
  93. package/examples/battle-benchmark-separation/assets/sfx/orc/hit/hit2.wav +0 -0
  94. package/examples/battle-benchmark-separation/assets/sfx/orc/hit/hit3.wav +0 -0
  95. package/examples/battle-benchmark-separation/assets/sfx/orc/miss/miss1.wav +0 -0
  96. package/examples/battle-benchmark-separation/assets/sfx/orc/miss/miss2.wav +0 -0
  97. package/examples/battle-benchmark-separation/assets/sfx/orc/miss/miss3.wav +0 -0
  98. package/examples/battle-benchmark-separation/assets/spritesheets/hero-atlas.json +246 -0
  99. package/examples/battle-benchmark-separation/assets/spritesheets/hero.png +0 -0
  100. package/examples/battle-benchmark-separation/assets/spritesheets/orc-atlas.json +246 -0
  101. package/examples/battle-benchmark-separation/assets/spritesheets/orc.png +0 -0
  102. package/examples/battle-benchmark-separation/assets/spritesheets/potion-atlas.json +68 -0
  103. package/examples/battle-benchmark-separation/assets/spritesheets/potion.png +0 -0
  104. package/examples/battle-benchmark-separation/dist/game.js +2 -0
  105. package/examples/battle-benchmark-separation/dist/game.js.LICENSE.txt +35 -0
  106. package/examples/battle-benchmark-separation/hud/damage-text.ts +46 -0
  107. package/examples/battle-benchmark-separation/hud/heal-text.ts +46 -0
  108. package/examples/battle-benchmark-separation/hud/hp-bar.ts +38 -0
  109. package/examples/battle-benchmark-separation/index.html +24 -0
  110. package/examples/battle-benchmark-separation/index.ts +41 -0
  111. package/examples/battle-benchmark-separation/objects/character.ts +225 -0
  112. package/examples/battle-benchmark-separation/objects/hero.ts +110 -0
  113. package/examples/battle-benchmark-separation/objects/orc.ts +213 -0
  114. package/examples/battle-benchmark-separation/objects/potion.ts +27 -0
  115. package/examples/battle-benchmark-separation/stage.ts +178 -0
  116. package/examples/battle-benchmark-separation2/assets/bgm/battle.mp3 +0 -0
  117. package/examples/battle-benchmark-separation2/assets/bitmap-fonts/white-peaberry.fnt +107 -0
  118. package/examples/battle-benchmark-separation2/assets/bitmap-fonts/white-peaberry.png +0 -0
  119. package/examples/battle-benchmark-separation2/assets/joystick/joystick.png +0 -0
  120. package/examples/battle-benchmark-separation2/assets/joystick/knob.png +0 -0
  121. package/examples/battle-benchmark-separation2/assets/sfx/hero/die/die.wav +0 -0
  122. package/examples/battle-benchmark-separation2/assets/sfx/hero/heal/heal.wav +0 -0
  123. package/examples/battle-benchmark-separation2/assets/sfx/hero/hit/hit1.wav +0 -0
  124. package/examples/battle-benchmark-separation2/assets/sfx/hero/hit/hit2.wav +0 -0
  125. package/examples/battle-benchmark-separation2/assets/sfx/hero/hit/hit3.wav +0 -0
  126. package/examples/battle-benchmark-separation2/assets/sfx/hero/miss/miss1.wav +0 -0
  127. package/examples/battle-benchmark-separation2/assets/sfx/hero/miss/miss2.wav +0 -0
  128. package/examples/battle-benchmark-separation2/assets/sfx/hero/miss/miss3.wav +0 -0
  129. package/examples/battle-benchmark-separation2/assets/sfx/orc/die/die.wav +0 -0
  130. package/examples/battle-benchmark-separation2/assets/sfx/orc/hit/hit1.wav +0 -0
  131. package/examples/battle-benchmark-separation2/assets/sfx/orc/hit/hit2.wav +0 -0
  132. package/examples/battle-benchmark-separation2/assets/sfx/orc/hit/hit3.wav +0 -0
  133. package/examples/battle-benchmark-separation2/assets/sfx/orc/miss/miss1.wav +0 -0
  134. package/examples/battle-benchmark-separation2/assets/sfx/orc/miss/miss2.wav +0 -0
  135. package/examples/battle-benchmark-separation2/assets/sfx/orc/miss/miss3.wav +0 -0
  136. package/examples/battle-benchmark-separation2/assets/spritesheets/hero-atlas.json +246 -0
  137. package/examples/battle-benchmark-separation2/assets/spritesheets/hero.png +0 -0
  138. package/examples/battle-benchmark-separation2/assets/spritesheets/orc-atlas.json +246 -0
  139. package/examples/battle-benchmark-separation2/assets/spritesheets/orc.png +0 -0
  140. package/examples/battle-benchmark-separation2/assets/spritesheets/potion-atlas.json +68 -0
  141. package/examples/battle-benchmark-separation2/assets/spritesheets/potion.png +0 -0
  142. package/examples/battle-benchmark-separation2/dist/game.js +2 -0
  143. package/examples/battle-benchmark-separation2/dist/game.js.LICENSE.txt +35 -0
  144. package/examples/battle-benchmark-separation2/hud/damage-text.ts +46 -0
  145. package/examples/battle-benchmark-separation2/hud/heal-text.ts +46 -0
  146. package/examples/battle-benchmark-separation2/hud/hp-bar.ts +38 -0
  147. package/examples/battle-benchmark-separation2/index.html +24 -0
  148. package/examples/battle-benchmark-separation2/index.ts +41 -0
  149. package/examples/battle-benchmark-separation2/objects/character.ts +195 -0
  150. package/examples/battle-benchmark-separation2/objects/hero.ts +110 -0
  151. package/examples/battle-benchmark-separation2/objects/orc.ts +213 -0
  152. package/examples/battle-benchmark-separation2/objects/potion.ts +27 -0
  153. package/examples/battle-benchmark-separation2/stage.ts +178 -0
  154. package/examples/dom-sprite-test/index.ts +6 -9
  155. package/examples/simple-battle/assets/spritesheets/hero-atlas.json +180 -223
  156. package/examples/simple-battle/assets/spritesheets/orc-atlas.json +180 -223
  157. package/examples/simple-battle/assets/spritesheets/potion-atlas.json +46 -61
  158. package/examples/simple-battle/hud/damage-text.ts +1 -0
  159. package/examples/simple-battle/hud/heal-text.ts +1 -0
  160. package/examples/simple-battle/objects/character.ts +3 -3
  161. package/examples/simple-battle/objects/hero.ts +3 -5
  162. package/examples/simple-battle/objects/orc.ts +3 -5
  163. package/examples/simple-battle/objects/potion.ts +0 -2
  164. package/examples/simple-battle/stage.ts +2 -4
  165. package/examples/sprite-test/index.ts +6 -9
  166. package/examples/webpack.config.js +4 -1
  167. package/lib/asset/loaders/audio.js +4 -1
  168. package/lib/asset/loaders/audio.js.map +1 -1
  169. package/lib/asset/loaders/binary.js +4 -1
  170. package/lib/asset/loaders/binary.js.map +1 -1
  171. package/lib/asset/loaders/bitmap-font.js +24 -21
  172. package/lib/asset/loaders/bitmap-font.js.map +1 -1
  173. package/lib/asset/loaders/font.js +3 -0
  174. package/lib/asset/loaders/font.js.map +1 -1
  175. package/lib/asset/loaders/spritesheet.js +12 -1
  176. package/lib/asset/loaders/spritesheet.js.map +1 -1
  177. package/lib/asset/loaders/text.js +3 -0
  178. package/lib/asset/loaders/text.js.map +1 -1
  179. package/lib/asset/loaders/texture.js +21 -26
  180. package/lib/asset/loaders/texture.js.map +1 -1
  181. package/lib/asset/preload.js.map +1 -1
  182. package/lib/collision/check-collision.js +16 -16
  183. package/lib/collision/check-collision.js.map +1 -1
  184. package/lib/dom/dom-animated-sprite.js +21 -36
  185. package/lib/dom/dom-animated-sprite.js.map +1 -1
  186. package/lib/dom/dom-game-object.js +9 -7
  187. package/lib/dom/dom-game-object.js.map +1 -1
  188. package/lib/dom/dom-particle.js.map +1 -1
  189. package/lib/index.js +1 -0
  190. package/lib/index.js.map +1 -1
  191. package/lib/node/core/dirty-number.js +0 -19
  192. package/lib/node/core/dirty-number.js.map +1 -1
  193. package/lib/node/core/renderable.js +7 -0
  194. package/lib/node/core/renderable.js.map +1 -1
  195. package/lib/node/core/transform.js +22 -11
  196. package/lib/node/core/transform.js.map +1 -1
  197. package/lib/node/ext/animated-sprite.js +3 -22
  198. package/lib/node/ext/animated-sprite.js.map +1 -1
  199. package/lib/node/ext/bitmap-text.js +7 -3
  200. package/lib/node/ext/bitmap-text.js.map +1 -1
  201. package/lib/node/ext/circle.js +18 -3
  202. package/lib/node/ext/circle.js.map +1 -1
  203. package/lib/node/ext/deplay.js +2 -0
  204. package/lib/node/ext/deplay.js.map +1 -1
  205. package/lib/node/ext/dom-container.js +2 -2
  206. package/lib/node/ext/dom-container.js.map +1 -1
  207. package/lib/node/ext/interval.js +2 -0
  208. package/lib/node/ext/interval.js.map +1 -1
  209. package/lib/node/ext/particle.js.map +1 -1
  210. package/lib/node/ext/rectangle.js +24 -4
  211. package/lib/node/ext/rectangle.js.map +1 -1
  212. package/lib/node/physics/physics-object.js +9 -29
  213. package/lib/node/physics/physics-object.js.map +1 -1
  214. package/lib/node/physics/physics-world.js +2 -0
  215. package/lib/node/physics/physics-world.js.map +1 -1
  216. package/lib/node/physics/rigidbodies.js +7 -0
  217. package/lib/node/physics/rigidbodies.js.map +1 -0
  218. package/lib/renderer/renderer.js +3 -2
  219. package/lib/renderer/renderer.js.map +1 -1
  220. package/lib/types/animation-atlas.js +2 -0
  221. package/lib/types/animation-atlas.js.map +1 -0
  222. package/lib/types/asset/loaders/audio.d.ts +1 -0
  223. package/lib/types/asset/loaders/audio.d.ts.map +1 -1
  224. package/lib/types/asset/loaders/binary.d.ts +1 -0
  225. package/lib/types/asset/loaders/binary.d.ts.map +1 -1
  226. package/lib/types/asset/loaders/bitmap-font.d.ts +1 -0
  227. package/lib/types/asset/loaders/bitmap-font.d.ts.map +1 -1
  228. package/lib/types/asset/loaders/font.d.ts +1 -0
  229. package/lib/types/asset/loaders/font.d.ts.map +1 -1
  230. package/lib/types/asset/loaders/spritesheet.d.ts +11 -3
  231. package/lib/types/asset/loaders/spritesheet.d.ts.map +1 -1
  232. package/lib/types/asset/loaders/text.d.ts +1 -0
  233. package/lib/types/asset/loaders/text.d.ts.map +1 -1
  234. package/lib/types/asset/loaders/texture.d.ts +1 -1
  235. package/lib/types/asset/loaders/texture.d.ts.map +1 -1
  236. package/lib/types/asset/preload.d.ts +2 -2
  237. package/lib/types/asset/preload.d.ts.map +1 -1
  238. package/lib/types/atlas copy.js +2 -0
  239. package/lib/types/atlas copy.js.map +1 -0
  240. package/lib/types/atlas.js +2 -0
  241. package/lib/types/atlas.js.map +1 -0
  242. package/lib/types/dom/dom-animated-sprite.d.ts +4 -10
  243. package/lib/types/dom/dom-animated-sprite.d.ts.map +1 -1
  244. package/lib/types/dom/dom-game-object.d.ts +1 -1
  245. package/lib/types/dom/dom-game-object.d.ts.map +1 -1
  246. package/lib/types/dom/dom-particle.d.ts.map +1 -1
  247. package/lib/types/index.d.ts +1 -0
  248. package/lib/types/index.d.ts.map +1 -1
  249. package/lib/types/node/core/dirty-number.d.ts +0 -8
  250. package/lib/types/node/core/dirty-number.d.ts.map +1 -1
  251. package/lib/types/node/core/renderable.d.ts +1 -0
  252. package/lib/types/node/core/renderable.d.ts.map +1 -1
  253. package/lib/types/node/core/transform.d.ts +4 -2
  254. package/lib/types/node/core/transform.d.ts.map +1 -1
  255. package/lib/types/node/ext/animated-sprite.d.ts +4 -10
  256. package/lib/types/node/ext/animated-sprite.d.ts.map +1 -1
  257. package/lib/types/node/ext/bitmap-text.d.ts.map +1 -1
  258. package/lib/types/node/ext/circle.d.ts +3 -3
  259. package/lib/types/node/ext/circle.d.ts.map +1 -1
  260. package/lib/types/node/ext/deplay.d.ts.map +1 -1
  261. package/lib/types/node/ext/dom-container.d.ts +1 -1
  262. package/lib/types/node/ext/dom-container.d.ts.map +1 -1
  263. package/lib/types/node/ext/interval.d.ts.map +1 -1
  264. package/lib/types/node/ext/particle.d.ts.map +1 -1
  265. package/lib/types/node/ext/rectangle.d.ts +4 -4
  266. package/lib/types/node/ext/rectangle.d.ts.map +1 -1
  267. package/lib/types/node/physics/physics-object.d.ts +2 -2
  268. package/lib/types/node/physics/physics-object.d.ts.map +1 -1
  269. package/lib/types/node/physics/physics-world.d.ts.map +1 -1
  270. package/lib/types/node/physics/rigidbodies.d.ts +23 -0
  271. package/lib/types/node/physics/rigidbodies.d.ts.map +1 -0
  272. package/lib/types/renderer/renderer.d.ts.map +1 -1
  273. package/lib/types/sprite-atlas.js +2 -0
  274. package/lib/types/sprite-atlas.js.map +1 -0
  275. package/lib/types/types/animation-atlas.d.ts +14 -0
  276. package/lib/types/types/animation-atlas.d.ts.map +1 -0
  277. package/lib/types/types/atlas copy.d.ts +12 -0
  278. package/lib/types/types/atlas copy.d.ts.map +1 -0
  279. package/lib/types/types/atlas.d.ts +16 -0
  280. package/lib/types/types/atlas.d.ts.map +1 -0
  281. package/lib/types/types/sprite-atlas.d.ts +13 -0
  282. package/lib/types/types/sprite-atlas.d.ts.map +1 -0
  283. package/package.json +1 -1
  284. package/src/asset/loaders/audio.ts +5 -2
  285. package/src/asset/loaders/binary.ts +5 -1
  286. package/src/asset/loaders/bitmap-font.ts +33 -27
  287. package/src/asset/loaders/font.ts +4 -0
  288. package/src/asset/loaders/spritesheet.ts +18 -5
  289. package/src/asset/loaders/text.ts +4 -0
  290. package/src/asset/loaders/texture.ts +19 -27
  291. package/src/asset/preload.ts +4 -8
  292. package/src/collision/check-collision.ts +16 -16
  293. package/src/dom/dom-animated-sprite.ts +24 -45
  294. package/src/dom/dom-game-object.ts +9 -6
  295. package/src/dom/dom-particle.ts +1 -1
  296. package/src/index.ts +1 -0
  297. package/src/node/core/dirty-number.ts +0 -24
  298. package/src/node/core/renderable.ts +7 -0
  299. package/src/node/core/transform.ts +23 -11
  300. package/src/node/ext/animated-sprite.ts +9 -29
  301. package/src/node/ext/bitmap-text.ts +7 -3
  302. package/src/node/ext/circle.ts +18 -3
  303. package/src/node/ext/deplay.ts +1 -0
  304. package/src/node/ext/dom-container.ts +2 -2
  305. package/src/node/ext/interval.ts +1 -0
  306. package/src/node/ext/particle.ts +1 -1
  307. package/src/node/ext/rectangle.ts +24 -4
  308. package/src/node/physics/physics-object.ts +11 -40
  309. package/src/node/physics/physics-world.ts +1 -0
  310. package/src/node/physics/rigidbodies.ts +14 -0
  311. package/src/renderer/renderer.ts +4 -3
  312. package/src/types/atlas.ts +17 -0
  313. package/examples/flappy-cat/assets/bgm/bgm.ogg +0 -0
  314. package/examples/flappy-cat/assets/images/base.png +0 -0
  315. package/examples/flappy-cat/assets/images/bg.png +0 -0
  316. package/examples/flappy-cat/assets/images/cat.png +0 -0
  317. package/examples/flappy-cat/assets/images/pipe-green.png +0 -0
  318. package/examples/flappy-cat/assets/images/pipe-red.png +0 -0
  319. package/examples/flappy-cat/assets/sfx/die.wav +0 -0
  320. package/examples/flappy-cat/assets/sfx/hit.wav +0 -0
  321. package/examples/flappy-cat/assets/sfx/point.wav +0 -0
  322. package/examples/flappy-cat/assets/sfx/wing.wav +0 -0
  323. package/examples/flappy-cat/dist/game.js +0 -0
  324. package/examples/flappy-cat/index.ts +0 -0
  325. /package/examples/{flappy-cat → auto-battle}/index.html +0 -0
@@ -0,0 +1,35 @@
1
+ /*!
2
+ * matter-js 0.20.0 by @liabru
3
+ * http://brm.io/matter-js/
4
+ * License MIT
5
+ *
6
+ * The MIT License (MIT)
7
+ *
8
+ * Copyright (c) Liam Brummitt and contributors.
9
+ *
10
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ * of this software and associated documentation files (the "Software"), to deal
12
+ * in the Software without restriction, including without limitation the rights
13
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ * copies of the Software, and to permit persons to whom the Software is
15
+ * furnished to do so, subject to the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be included in
18
+ * all copies or substantial portions of the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
+ * THE SOFTWARE.
27
+ */
28
+
29
+ /**
30
+ * tiny-lru
31
+ *
32
+ * @copyright 2025 Jason Mulligan <jason.mulligan@avoidwork.com>
33
+ * @license BSD-3-Clause
34
+ * @version 11.4.5
35
+ */
@@ -0,0 +1,46 @@
1
+ import { BitmapTextNode, GameObjectOptions } from '../../../src/index'
2
+
3
+ export type DamageTextOptions = {
4
+ damage: number
5
+ } & GameObjectOptions
6
+
7
+ export class DamageText extends BitmapTextNode {
8
+ #velocityY = -50
9
+ #gravity = 100
10
+ #lifetime = 1.0
11
+ #elapsed = 0
12
+ #fadeStart = 0.5
13
+ #initialScale = 1.0
14
+ #targetScale = 1.2
15
+
16
+ constructor(options: DamageTextOptions) {
17
+ super({
18
+ ...options,
19
+ text: `-${options.damage}`,
20
+ fnt: 'assets/bitmap-fonts/white-peaberry.fnt',
21
+ src: 'assets/bitmap-fonts/white-peaberry.png'
22
+ })
23
+ }
24
+
25
+ protected override update(dt: number) {
26
+ if (this.paused) return
27
+ super.update(dt)
28
+
29
+ this.#elapsed += dt
30
+ this.#velocityY += this.#gravity * dt
31
+ this.y += this.#velocityY * dt
32
+
33
+ const progress = Math.min(this.#elapsed / this.#lifetime, 1)
34
+ const scale = this.#initialScale + (this.#targetScale - this.#initialScale) * progress
35
+ this.scale = scale
36
+
37
+ if (this.#elapsed > this.#fadeStart) {
38
+ const fadeProgress = (this.#elapsed - this.#fadeStart) / (this.#lifetime - this.#fadeStart)
39
+ this.alpha = Math.max(1 - fadeProgress, 0)
40
+ }
41
+
42
+ if (this.#elapsed >= this.#lifetime) {
43
+ this.remove()
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,46 @@
1
+ import { BitmapTextNode, GameObjectOptions } from '../../../src/index'
2
+
3
+ export type HealTextOptions = {
4
+ hp: number
5
+ } & GameObjectOptions
6
+
7
+ export class HealText extends BitmapTextNode {
8
+ #velocityY = -50
9
+ #gravity = 100
10
+ #lifetime = 1.0
11
+ #elapsed = 0
12
+ #fadeStart = 0.5
13
+ #initialScale = 1.0
14
+ #targetScale = 1.2
15
+
16
+ constructor(options: HealTextOptions) {
17
+ super({
18
+ ...options,
19
+ text: `+${options.hp}`,
20
+ fnt: 'assets/bitmap-fonts/white-peaberry.fnt',
21
+ src: 'assets/bitmap-fonts/white-peaberry.png'
22
+ })
23
+ }
24
+
25
+ protected override update(dt: number) {
26
+ if (this.paused) return
27
+ super.update(dt)
28
+
29
+ this.#elapsed += dt
30
+ this.#velocityY += this.#gravity * dt
31
+ this.y += this.#velocityY * dt
32
+
33
+ const progress = Math.min(this.#elapsed / this.#lifetime, 1)
34
+ const scale = this.#initialScale + (this.#targetScale - this.#initialScale) * progress
35
+ this.scale = scale
36
+
37
+ if (this.#elapsed > this.#fadeStart) {
38
+ const fadeProgress = (this.#elapsed - this.#fadeStart) / (this.#lifetime - this.#fadeStart)
39
+ this.alpha = Math.max(1 - fadeProgress, 0)
40
+ }
41
+
42
+ if (this.#elapsed >= this.#lifetime) {
43
+ this.remove()
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,38 @@
1
+ import { GameObject, GameObjectOptions, RectangleNode } from '../../../src'
2
+
3
+ const HP_BAR_WIDTH = 26
4
+
5
+ export type HpBarOptions = {
6
+ maxHp: number
7
+ hp: number
8
+ } & GameObjectOptions
9
+
10
+ export class HpBar extends GameObject {
11
+ #bg = new RectangleNode({ width: HP_BAR_WIDTH, height: 4, fill: '#000000', alpha: 0.4 })
12
+ #fg = new RectangleNode({ width: HP_BAR_WIDTH, height: 4, fill: '#ff3b30' })
13
+
14
+ #maxHp: number
15
+ #hp: number
16
+
17
+ constructor(options: HpBarOptions) {
18
+ super(options)
19
+ this.#maxHp = options.maxHp
20
+ this.#hp = options.hp
21
+ this.add(this.#bg, this.#fg)
22
+ this.#updateFg()
23
+ }
24
+
25
+ #updateFg() {
26
+ const ratio = Math.max(0, Math.min(1, this.#hp / this.#maxHp))
27
+ const newWidth = HP_BAR_WIDTH * ratio
28
+ this.#fg.width = newWidth
29
+ this.#fg.x = -(HP_BAR_WIDTH - newWidth) / 2
30
+ }
31
+
32
+ set hp(hp: number) {
33
+ this.#hp = hp
34
+ this.#updateFg()
35
+ }
36
+
37
+ get hp() { return this.#hp }
38
+ }
@@ -0,0 +1,24 @@
1
+ <!doctype html>
2
+ <html>
3
+
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <meta name="viewport" content="width=device-width,initial-scale=1">
7
+ <style>
8
+ html,
9
+ body {
10
+ width: 100%;
11
+ height: 100%;
12
+ margin: 0;
13
+ padding: 0;
14
+ overflow: hidden;
15
+ background-color: #000;
16
+ }
17
+ </style>
18
+ </head>
19
+
20
+ <body>
21
+ <script src="dist/game.js"></script>
22
+ </body>
23
+
24
+ </html>
@@ -0,0 +1,41 @@
1
+ import { enableDebug, preload, Renderer } from '../../src'
2
+ import heroAtlas from './assets/spritesheets/hero-atlas.json'
3
+ import orcAtlas from './assets/spritesheets/orc-atlas.json'
4
+ import potionAtlas from './assets/spritesheets/potion-atlas.json'
5
+ import { Stage } from './stage'
6
+
7
+ if (process.env.NODE_ENV === 'development') {
8
+ enableDebug()
9
+ }
10
+
11
+ await preload([
12
+ { src: 'assets/spritesheets/hero.png', atlas: heroAtlas },
13
+ { src: 'assets/spritesheets/orc.png', atlas: orcAtlas },
14
+ { src: 'assets/spritesheets/potion.png', atlas: potionAtlas },
15
+ { fnt: 'assets/bitmap-fonts/white-peaberry.fnt', src: 'assets/bitmap-fonts/white-peaberry.png' },
16
+ 'assets/bgm/battle.mp3',
17
+ 'assets/sfx/hero/hit/hit1.wav',
18
+ 'assets/sfx/hero/hit/hit2.wav',
19
+ 'assets/sfx/hero/hit/hit3.wav',
20
+ 'assets/sfx/hero/miss/miss1.wav',
21
+ 'assets/sfx/hero/miss/miss2.wav',
22
+ 'assets/sfx/hero/miss/miss3.wav',
23
+ 'assets/sfx/hero/heal/heal.wav',
24
+ 'assets/sfx/hero/die/die.wav',
25
+ 'assets/sfx/orc/hit/hit1.wav',
26
+ 'assets/sfx/orc/hit/hit2.wav',
27
+ 'assets/sfx/orc/hit/hit3.wav',
28
+ 'assets/sfx/orc/miss/miss1.wav',
29
+ 'assets/sfx/orc/miss/miss2.wav',
30
+ 'assets/sfx/orc/miss/miss3.wav',
31
+ 'assets/sfx/orc/die/die.wav',
32
+ ])
33
+
34
+ const renderer = new Renderer(document.body, {
35
+ backgroundColor: '#304C79',
36
+ layers: [
37
+ { name: 'hud', drawOrder: 1 }
38
+ ],
39
+ })
40
+
41
+ renderer.add(new Stage())
@@ -0,0 +1,195 @@
1
+ import { EventMap } from '@webtaku/event-emitter'
2
+ import {
3
+ AnimatedSpriteNode, debugMode, DelayNode, GameObject,
4
+ PhysicsObjectOptions, RectangleCollider, RectangleNode,
5
+ RectangleRigidbody
6
+ } from '../../../src'
7
+ import { DamageText } from '../hud/damage-text'
8
+ import { HealText } from '../hud/heal-text'
9
+ import { HpBar } from '../hud/hp-bar'
10
+
11
+ export type CharacterOptions = {
12
+ maxHp: number
13
+ hp: number
14
+ rigidbody: RectangleRigidbody
15
+ hitbox: RectangleCollider
16
+ hurtbox: RectangleCollider
17
+ /** 밀어내기 강도 (프레임 보정 전), 0으로 두면 비활성화 */
18
+ separationStrength?: number
19
+ } & PhysicsObjectOptions
20
+
21
+ export abstract class Character<E extends EventMap = EventMap> extends GameObject<E & {
22
+ changeHp: (damage: number) => void
23
+ dead: () => void
24
+ }> {
25
+ /** ==== Separation 레지스트리 ==== */
26
+ private static readonly _registry = new Set<Character>()
27
+ static get all(): ReadonlySet<Character> { return this._registry }
28
+
29
+ /** 같은 팀/유형 제외 등의 필터가 필요하면 오버라이드 */
30
+ protected canSeparateWith(other: Character): boolean {
31
+ return !this.dead && !other.dead && other !== this
32
+ }
33
+
34
+ /** ===== 기본 스탯/컴포넌트 ===== */
35
+ maxHp: number
36
+ hp: number
37
+ dead = false
38
+
39
+ /** 충돌은 collider 기준으로만 처리 */
40
+ rigidbody: RectangleRigidbody
41
+ hitbox: RectangleCollider
42
+ hurtbox: RectangleCollider
43
+
44
+ #hpBar: HpBar
45
+ protected _sprite?: AnimatedSpriteNode
46
+ #hitboxDebugNode?: RectangleNode
47
+ #tintDelay?: DelayNode
48
+
49
+ /** 밀어내기 강도 */
50
+ protected separationStrength: number
51
+
52
+ constructor(options: CharacterOptions) {
53
+ super({ ...options, useYSort: true })
54
+ this.maxHp = options.maxHp
55
+ this.hp = options.hp
56
+
57
+ // collider 기반 처리
58
+ this.rigidbody = { ...options.rigidbody } // 원본 참조 대신 복사해 안전하게 사용
59
+ this.hitbox = { ...options.hitbox }
60
+ this.hurtbox = { ...options.hurtbox }
61
+
62
+ this.separationStrength = options.separationStrength ?? 1.0
63
+
64
+ this.#hpBar = new HpBar({ y: -30, maxHp: options.maxHp, hp: options.hp, layer: 'hud' })
65
+ this.add(this.#hpBar)
66
+
67
+ if (debugMode) {
68
+ this.add(new RectangleNode({ ...options.rigidbody, stroke: 'yellow', alpha: 0.5, layer: 'hud' }))
69
+ this.#hitboxDebugNode = new RectangleNode({ ...this.hitbox, stroke: 'red', alpha: 0.5, layer: 'hud' })
70
+ this.add(this.#hitboxDebugNode)
71
+ this.add(new RectangleNode({ ...this.hurtbox, stroke: 'green', alpha: 0.5, layer: 'hud' }))
72
+ }
73
+
74
+ Character._registry.add(this)
75
+ }
76
+
77
+ /** 제거 시 레지스트리에서 해제 */
78
+ override remove(...args: any[]) {
79
+ Character._registry.delete(this)
80
+ // @ts-ignore
81
+ return super.remove?.(...args)
82
+ }
83
+
84
+ set hitboxX(x: number) {
85
+ this.hitbox.x = x
86
+ if (this.#hitboxDebugNode) this.#hitboxDebugNode.x = x
87
+ }
88
+
89
+ takeDamage(damage: number) {
90
+ if (this.dead) return
91
+
92
+ this.hp -= damage
93
+ this.#hpBar.hp = this.hp
94
+
95
+ if (this._sprite) {
96
+ this._sprite.tint = 0xff0000
97
+ this.#tintDelay?.remove()
98
+ this.#tintDelay = new DelayNode(0.1, () => this._sprite!.tint = 0xffffff)
99
+ this.add(this.#tintDelay)
100
+ }
101
+ ; (this as any).emit('changeHp', damage)
102
+ this.add(new DamageText({ y: -20, damage, layer: 'hud' }))
103
+
104
+ if (this.hp <= 0) {
105
+ this.dead = true
106
+ this.onDie()
107
+ ; (this as any).emit('dead')
108
+ }
109
+ }
110
+
111
+ heal(amount: number) {
112
+ if (this.dead) return
113
+
114
+ this.hp = Math.min(this.maxHp, this.hp + amount)
115
+ this.#hpBar.hp = this.hp
116
+
117
+ if (this._sprite) {
118
+ this._sprite.tint = 0x00ff00
119
+ this.#tintDelay?.remove()
120
+ this.#tintDelay = new DelayNode(0.1, () => this._sprite!.tint = 0xffffff)
121
+ this.add(this.#tintDelay)
122
+ }
123
+ ; (this as any).emit('changeHp', amount)
124
+ this.add(new HealText({ y: -20, hp: amount, layer: 'hud' }))
125
+ }
126
+
127
+ /** ===== 핵심: collider 기반 소프트 충돌 해소 ===== */
128
+ protected applySeparationByCollider(dt: number) {
129
+ if (this.separationStrength <= 0) return
130
+
131
+ // A의 월드 기준 collider 사각형
132
+ const aLeft = this.x
133
+ const aTop = this.y
134
+ const aRight = aLeft + (this.rigidbody?.width ?? 0)
135
+ const aBottom = aTop + (this.rigidbody?.height ?? 0)
136
+
137
+ for (const other of Character.all) {
138
+ if (!this.canSeparateWith(other)) continue
139
+
140
+ const bLeft = other.x
141
+ const bTop = other.y
142
+ const bRight = bLeft + (other.rigidbody?.width ?? 0)
143
+ const bBottom = bTop + (other.rigidbody?.height ?? 0)
144
+
145
+ // AABB 교차 판정
146
+ const intersect =
147
+ aLeft < bRight && aRight > bLeft && aTop < bBottom && aBottom > bTop
148
+ if (!intersect) continue
149
+
150
+ // 축 분리: x/y 중 더 작은 침투량으로 해소
151
+ const overlapX = Math.min(aRight - bLeft, bRight - aLeft)
152
+ const overlapY = Math.min(aBottom - bTop, bBottom - aTop)
153
+
154
+ // 해소 벡터
155
+ let sepX = 0, sepY = 0
156
+ if (overlapX < overlapY) {
157
+ // X축으로 밀어냄: 방향은 중심 비교로 결정
158
+ const aCenterX = (aLeft + aRight) * 0.5
159
+ const bCenterX = (bLeft + bRight) * 0.5
160
+ const dir = Math.sign(aCenterX - bCenterX) || (Math.random() < 0.5 ? 1 : -1)
161
+ sepX = dir * overlapX
162
+ } else {
163
+ // Y축으로 밀어냄
164
+ const aCenterY = (aTop + aBottom) * 0.5
165
+ const bCenterY = (bTop + bBottom) * 0.5
166
+ const dir = Math.sign(aCenterY - bCenterY) || (Math.random() < 0.5 ? 1 : -1)
167
+ sepY = dir * overlapY
168
+ }
169
+
170
+ // 반씩 나눠 밀기 + 프레임 보정 + 강도
171
+ const push = this.separationStrength * Math.min(dt ?? 0.016, 0.033)
172
+ const mx = (sepX * 0.5) * push
173
+ const my = (sepY * 0.5) * push
174
+
175
+ this.x += mx
176
+ this.y += my
177
+ other.x -= mx
178
+ other.y -= my
179
+ }
180
+ }
181
+
182
+ /** 엔진의 업데이트 훅 이름이 다르면 여기를 맞춰주세요 */
183
+ protected override update(dt: number) {
184
+ if (this.paused) return
185
+
186
+ // 원래 업데이트
187
+ // @ts-ignore
188
+ super.update?.(dt)
189
+
190
+ // collider 기반 소프트 충돌
191
+ this.applySeparationByCollider(dt)
192
+ }
193
+
194
+ protected abstract onDie(): void
195
+ }
@@ -0,0 +1,110 @@
1
+ import { AnimatedSpriteNode, ColliderType, DelayNode, GameObjectOptions, RigidbodyType, sfxPlayer } from '../../../src/index'
2
+ import heroAtlas from '../assets/spritesheets/hero-atlas.json'
3
+ import { Character } from './character'
4
+
5
+ const HERO_MOVE_SPEED = 200 as const
6
+ const HERO_HITBOX_X = 24 as const
7
+ const HERO_ATTACK_DAMAGE = 60 as const
8
+
9
+ export class Hero extends Character<{
10
+ hit: (damage: number) => void
11
+ dead: () => void
12
+ }> {
13
+ protected _sprite: AnimatedSpriteNode
14
+
15
+ #cachedVelX = 0
16
+ #cachedVelY = 0
17
+ #prevX = this.x
18
+ #attacking = false
19
+
20
+ constructor(options?: GameObjectOptions) {
21
+ super({
22
+ ...options,
23
+ maxHp: 100000,
24
+ hp: 100000,
25
+ rigidbody: { type: RigidbodyType.Rectangle, width: 30, height: 30 },
26
+ hitbox: { type: ColliderType.Rectangle, width: 32, height: 52, x: HERO_HITBOX_X, y: -8 },
27
+ hurtbox: { type: ColliderType.Rectangle, width: 24, height: 40, x: 0, y: -4 },
28
+ isStatic: true
29
+ })
30
+
31
+ this._sprite = new AnimatedSpriteNode({
32
+ src: 'assets/spritesheets/hero.png',
33
+ atlas: heroAtlas,
34
+ animation: 'idle',
35
+ scale: 2
36
+ })
37
+ this._sprite.on('animationend', (animation) => {
38
+ if (animation.startsWith('attack')) {
39
+ this.#attacking = false
40
+ this._sprite.animation = 'idle'
41
+ } else if (animation === 'die') {
42
+ this.emit('dead')
43
+ }
44
+ })
45
+ this.add(this._sprite)
46
+ }
47
+
48
+ move(radian: number, distance: number) {
49
+ if (this.dead) return
50
+ this.#cachedVelX = Math.cos(radian) * distance * HERO_MOVE_SPEED
51
+ this.#cachedVelY = Math.sin(radian) * distance * HERO_MOVE_SPEED
52
+ }
53
+
54
+ stop() {
55
+ this.#cachedVelX = 0
56
+ this.#cachedVelY = 0
57
+ }
58
+
59
+ attack() {
60
+ if (this.dead || this.#attacking) return
61
+ this.#attacking = true
62
+
63
+ this._sprite.animation = Math.floor(Math.random() * 2) ? 'attack1' : 'attack2'
64
+
65
+ this.add(new DelayNode(0.3, () => this.emit('hit', HERO_ATTACK_DAMAGE)))
66
+
67
+ sfxPlayer.playRandom(
68
+ 'assets/sfx/hero/miss/miss1.wav',
69
+ 'assets/sfx/hero/miss/miss2.wav',
70
+ 'assets/sfx/hero/miss/miss3.wav',
71
+ )
72
+ }
73
+
74
+ protected override update(dt: number) {
75
+ if (this.paused) return
76
+ super.update(dt)
77
+
78
+ this.x += this.#cachedVelX * dt
79
+ this.y += this.#cachedVelY * dt
80
+
81
+ if (this._sprite && this.x !== this.#prevX) {
82
+ const scale = Math.abs(this._sprite.scaleX)
83
+ this._sprite.scaleX = this.x > this.#prevX ? scale : -scale
84
+ this.hitboxX = this.x > this.#prevX ? HERO_HITBOX_X : -HERO_HITBOX_X
85
+ }
86
+ this.#prevX = this.x
87
+ }
88
+
89
+ override takeDamage(damage: number) {
90
+ super.takeDamage(damage)
91
+ sfxPlayer.playRandom(
92
+ 'assets/sfx/hero/hit/hit1.wav',
93
+ 'assets/sfx/hero/hit/hit2.wav',
94
+ 'assets/sfx/hero/hit/hit3.wav'
95
+ )
96
+ }
97
+
98
+ override heal(amount: number) {
99
+ super.heal(amount)
100
+ sfxPlayer.play('assets/sfx/hero/heal/heal.wav')
101
+ }
102
+
103
+ protected override onDie() {
104
+ this._sprite.animation = 'die'
105
+ this.#cachedVelX = 0
106
+ this.#cachedVelY = 0
107
+
108
+ sfxPlayer.play('assets/sfx/hero/die/die.wav')
109
+ }
110
+ }