kiwiengine 0.5.2 → 0.5.4

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 +2 -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 +2 -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,225 @@
1
+ import { EventMap } from '@webtaku/event-emitter'
2
+ import {
3
+ AnimatedSpriteNode,
4
+ debugMode,
5
+ DelayNode,
6
+ GameObject,
7
+ PhysicsObjectOptions,
8
+ RectangleCollider,
9
+ RectangleNode,
10
+ RectangleRigidbody
11
+ } from '../../../src'
12
+ import { DamageText } from '../hud/damage-text'
13
+ import { HealText } from '../hud/heal-text'
14
+ import { HpBar } from '../hud/hp-bar'
15
+
16
+ export type CharacterOptions = {
17
+ maxHp: number
18
+ hp: number
19
+ rigidbody: RectangleRigidbody
20
+ hitbox: RectangleCollider
21
+ hurtbox: RectangleCollider
22
+ } & PhysicsObjectOptions
23
+
24
+ export abstract class Character<E extends EventMap = EventMap> extends GameObject<E & {
25
+ changeHp: (damage: number) => void
26
+ dead: () => void
27
+ }> {
28
+ // ── 고유 ID: 한 페어를 한 번만 해결하기 위한 편향 ─────────────────
29
+ private static _uidCounter = 1
30
+ readonly uid = Character._uidCounter++
31
+
32
+ maxHp: number
33
+ hp: number
34
+ dead = false
35
+
36
+ rigidbody: RectangleRigidbody
37
+ hitbox: RectangleCollider
38
+ hurtbox: RectangleCollider
39
+
40
+ #hpBar: HpBar
41
+ protected _sprite?: AnimatedSpriteNode
42
+ #hitboxDebugNode?: RectangleNode
43
+ #tintDelay?: DelayNode
44
+
45
+ // ── 분리 파라미터/상태 (안정화 + 시간 기반 쓰로틀) ────────────────
46
+ #beta = 0.35 // 부분 보정 계수(0~1)
47
+ #maxPushPerPair = 6 // 한 페어당 프레임 최대 밀기(픽셀)
48
+ #eps = 1e-3 // 대칭 진동 방지용 미세 오프셋
49
+ #warmupFrames = 30 // 스폰 후 워밍업 프레임 수(강/자주 분리)
50
+ #spawnJitter = 0.25 // 스폰 시 위치에 미세 난수 섞기
51
+
52
+ // dt 누적 기반 쓰로틀(초)
53
+ #sepTimerSec = 0
54
+ #sepIntervalSec = 0.033 // 평상시 분리 주기(약 2프레임 @60fps)
55
+ #sepJitterSec = Math.random() * 0.01 // 동기화 붕괴용
56
+
57
+ constructor(options: CharacterOptions) {
58
+ super({ ...options, useYSort: true })
59
+ this.maxHp = options.maxHp
60
+ this.hp = options.hp
61
+ this.rigidbody = options.rigidbody
62
+ this.hitbox = options.hitbox
63
+ this.hurtbox = options.hurtbox
64
+
65
+ // 스폰 시 완전 대칭 상태 깨기
66
+ if (this.#spawnJitter > 0) {
67
+ this.x += (Math.random() * 2 - 1) * this.#spawnJitter
68
+ this.y += (Math.random() * 2 - 1) * this.#spawnJitter
69
+ }
70
+
71
+ this.#hpBar = new HpBar({ y: -30, maxHp: options.maxHp, hp: options.hp, layer: 'hud' })
72
+ this.add(this.#hpBar)
73
+
74
+ if (debugMode) {
75
+ this.add(new RectangleNode({ ...options.rigidbody, stroke: 'yellow', alpha: 0.5, layer: 'hud' }))
76
+ this.#hitboxDebugNode = new RectangleNode({ ...this.hitbox, stroke: 'red', alpha: 0.5, layer: 'hud' })
77
+ this.add(this.#hitboxDebugNode)
78
+ this.add(new RectangleNode({ ...this.hurtbox, stroke: 'green', alpha: 0.5, layer: 'hud' }))
79
+ }
80
+ }
81
+
82
+ set hitboxX(x: number) {
83
+ this.hitbox.x = x
84
+ if (this.#hitboxDebugNode) this.#hitboxDebugNode.x = x
85
+ }
86
+
87
+ takeDamage(damage: number) {
88
+ if (this.dead) return
89
+
90
+ this.hp -= damage
91
+ this.#hpBar.hp = this.hp
92
+
93
+ if (this._sprite) {
94
+ this._sprite.tint = 0xff0000
95
+ this.#tintDelay?.remove()
96
+ this.#tintDelay = new DelayNode(0.1, () => (this._sprite!.tint = 0xffffff))
97
+ this.add(this.#tintDelay)
98
+ }
99
+ ; (this as any).emit('changeHp', damage)
100
+ this.add(new DamageText({ y: -20, damage, layer: 'hud' }))
101
+
102
+ if (this.hp <= 0) {
103
+ this.dead = true
104
+ this.onDie()
105
+ ; (this as any).emit('dead')
106
+ }
107
+ }
108
+
109
+ heal(amount: number) {
110
+ if (this.dead) return
111
+
112
+ this.hp = Math.min(this.maxHp, this.hp + amount)
113
+ this.#hpBar.hp = this.hp
114
+
115
+ if (this._sprite) {
116
+ this._sprite.tint = 0x00ff00
117
+ this.#tintDelay?.remove()
118
+ this.#tintDelay = new DelayNode(0.1, () => (this._sprite!.tint = 0xffffff))
119
+ this.add(this.#tintDelay)
120
+ }
121
+ ; (this as any).emit('changeHp', amount)
122
+ this.add(new HealText({ y: -20, hp: amount, layer: 'hud' }))
123
+ }
124
+
125
+ protected abstract onDie(): void
126
+
127
+ // ── 매 프레임: 이동/전투 처리 후 겹침 분리 수행 ────────────────────
128
+ protected override update(dt: number) {
129
+ if (this.paused) return
130
+ super.update(dt)
131
+
132
+ // 워밍업 동안: 더 자주(간격 0 → 매 프레임), 조금 더 강하게(β↑)
133
+ const inWarmup = this.#warmupFrames-- > 0
134
+ const intervalSec = inWarmup ? 0 : this.#sepIntervalSec
135
+ const beta = inWarmup ? Math.min(0.6, this.#beta + 0.15) : this.#beta
136
+
137
+ this.separateFromNeighbors(dt, 48, 1, intervalSec, beta)
138
+ }
139
+
140
+ // ────────────────────────────────────────────────────────────────
141
+ // 겹침 방지(안정화 + dt 기반 쓰로틀)
142
+ separateFromNeighbors(
143
+ dt: number,
144
+ radius = 48,
145
+ iterations = 1,
146
+ intervalSec = 0, // 0이면 매 프레임 실행
147
+ beta = this.#beta
148
+ ) {
149
+ if (this.dead) return
150
+ const parent = this.parent as any
151
+ if (!parent || !parent.children) return
152
+
153
+ // 시간 기반 쓰로틀 (초 단위)
154
+ if (intervalSec > 0) {
155
+ this.#sepTimerSec += dt
156
+ if (this.#sepTimerSec + this.#sepJitterSec < intervalSec) return
157
+ this.#sepTimerSec = 0
158
+ }
159
+
160
+ const cx = this.x
161
+ const cy = this.y
162
+ const hw = (this.rigidbody.width ?? 0) * 0.5
163
+ const hh = (this.rigidbody.height ?? 0) * 0.5
164
+ const radius2 = radius * radius
165
+ const eps = this.#eps
166
+ const maxPush = this.#maxPushPerPair
167
+
168
+ for (let iter = 0; iter < iterations; iter++) {
169
+ for (const other of parent.children as any[]) {
170
+ if (other === this) continue
171
+ if (!(other instanceof Character)) continue
172
+ if (other.dead) continue
173
+
174
+ // 한 페어는 uid 작은 쪽만 처리 → 동시 되밀기 방지
175
+ if (this.uid > (other as Character).uid) continue
176
+
177
+ const or = other.rigidbody
178
+ if (!or) continue
179
+
180
+ const ocx = other.x
181
+ const ocy = other.y
182
+
183
+ // 원거리 프리체크
184
+ const dx0 = ocx - cx
185
+ const dy0 = ocy - cy
186
+ if (dx0 * dx0 + dy0 * dy0 > radius2) continue
187
+
188
+ // AABB 침투량
189
+ const ohw = (or.width ?? 0) * 0.5
190
+ const ohh = (or.height ?? 0) * 0.5
191
+
192
+ const dx = ocx - cx
193
+ const px = (hw + ohw) - Math.abs(dx)
194
+ if (px <= 0) continue
195
+
196
+ const dy = ocy - cy
197
+ const py = (hh + ohh) - Math.abs(dy)
198
+ if (py <= 0) continue
199
+
200
+ // 작은 축으로 부분 보정 + 푸시 캡 + ε
201
+ if (px < py) {
202
+ const push = Math.min(maxPush, Math.max(0, px * beta) + eps)
203
+ const half = push * 0.5
204
+ if (dx > 0) {
205
+ this.x -= half
206
+ other.x += half
207
+ } else {
208
+ this.x += half
209
+ other.x -= half
210
+ }
211
+ } else {
212
+ const push = Math.min(maxPush, Math.max(0, py * beta) + eps)
213
+ const half = push * 0.5
214
+ if (dy > 0) {
215
+ this.y -= half
216
+ other.y += half
217
+ } else {
218
+ this.y += half
219
+ other.y -= half
220
+ }
221
+ }
222
+ }
223
+ }
224
+ }
225
+ }
@@ -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
+ }