kiwiengine 0.0.1-alpha → 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.
- package/README.ko.md +550 -0
- package/README.md +575 -4
- package/examples/auto-battle/assets/bgm/battle.mp3 +0 -0
- package/examples/auto-battle/assets/bitmap-fonts/white-peaberry.fnt +107 -0
- package/examples/auto-battle/assets/bitmap-fonts/white-peaberry.png +0 -0
- package/examples/auto-battle/assets/joystick/joystick.png +0 -0
- package/examples/auto-battle/assets/joystick/knob.png +0 -0
- package/examples/auto-battle/assets/sfx/hero/die/die.wav +0 -0
- package/examples/auto-battle/assets/sfx/hero/heal/heal.wav +0 -0
- package/examples/auto-battle/assets/sfx/hero/hit/hit1.wav +0 -0
- package/examples/auto-battle/assets/sfx/hero/hit/hit2.wav +0 -0
- package/examples/auto-battle/assets/sfx/hero/hit/hit3.wav +0 -0
- package/examples/auto-battle/assets/sfx/hero/miss/miss1.wav +0 -0
- package/examples/auto-battle/assets/sfx/hero/miss/miss2.wav +0 -0
- package/examples/auto-battle/assets/sfx/hero/miss/miss3.wav +0 -0
- package/examples/auto-battle/assets/sfx/orc/die/die.wav +0 -0
- package/examples/auto-battle/assets/sfx/orc/hit/hit1.wav +0 -0
- package/examples/auto-battle/assets/sfx/orc/hit/hit2.wav +0 -0
- package/examples/auto-battle/assets/sfx/orc/hit/hit3.wav +0 -0
- package/examples/auto-battle/assets/sfx/orc/miss/miss1.wav +0 -0
- package/examples/auto-battle/assets/sfx/orc/miss/miss2.wav +0 -0
- package/examples/auto-battle/assets/sfx/orc/miss/miss3.wav +0 -0
- package/examples/auto-battle/assets/spritesheets/hero-atlas.json +246 -0
- package/examples/auto-battle/assets/spritesheets/hero.png +0 -0
- package/examples/auto-battle/assets/spritesheets/orc-atlas.json +246 -0
- package/examples/auto-battle/assets/spritesheets/orc.png +0 -0
- package/examples/auto-battle/assets/spritesheets/potion-atlas.json +68 -0
- package/examples/auto-battle/assets/spritesheets/potion.png +0 -0
- package/examples/auto-battle/dist/game.js +2 -0
- package/examples/auto-battle/dist/game.js.LICENSE.txt +35 -0
- package/examples/auto-battle/hud/damage-text.ts +46 -0
- package/examples/auto-battle/hud/heal-text.ts +46 -0
- package/examples/auto-battle/hud/hp-bar.ts +38 -0
- package/examples/auto-battle/index.ts +41 -0
- package/examples/auto-battle/objects/character.ts +95 -0
- package/examples/auto-battle/objects/hero.ts +119 -0
- package/examples/auto-battle/objects/orc.ts +107 -0
- package/examples/auto-battle/objects/potion.ts +27 -0
- package/examples/auto-battle/stage.ts +366 -0
- package/examples/battle-benchmark-matterjs/assets/bgm/battle.mp3 +0 -0
- package/examples/battle-benchmark-matterjs/assets/bitmap-fonts/white-peaberry.fnt +107 -0
- package/examples/battle-benchmark-matterjs/assets/bitmap-fonts/white-peaberry.png +0 -0
- package/examples/battle-benchmark-matterjs/assets/joystick/joystick.png +0 -0
- package/examples/battle-benchmark-matterjs/assets/joystick/knob.png +0 -0
- package/examples/battle-benchmark-matterjs/assets/sfx/hero/die/die.wav +0 -0
- package/examples/battle-benchmark-matterjs/assets/sfx/hero/heal/heal.wav +0 -0
- package/examples/battle-benchmark-matterjs/assets/sfx/hero/hit/hit1.wav +0 -0
- package/examples/battle-benchmark-matterjs/assets/sfx/hero/hit/hit2.wav +0 -0
- package/examples/battle-benchmark-matterjs/assets/sfx/hero/hit/hit3.wav +0 -0
- package/examples/battle-benchmark-matterjs/assets/sfx/hero/miss/miss1.wav +0 -0
- package/examples/battle-benchmark-matterjs/assets/sfx/hero/miss/miss2.wav +0 -0
- package/examples/battle-benchmark-matterjs/assets/sfx/hero/miss/miss3.wav +0 -0
- package/examples/battle-benchmark-matterjs/assets/sfx/orc/die/die.wav +0 -0
- package/examples/battle-benchmark-matterjs/assets/sfx/orc/hit/hit1.wav +0 -0
- package/examples/battle-benchmark-matterjs/assets/sfx/orc/hit/hit2.wav +0 -0
- package/examples/battle-benchmark-matterjs/assets/sfx/orc/hit/hit3.wav +0 -0
- package/examples/battle-benchmark-matterjs/assets/sfx/orc/miss/miss1.wav +0 -0
- package/examples/battle-benchmark-matterjs/assets/sfx/orc/miss/miss2.wav +0 -0
- package/examples/battle-benchmark-matterjs/assets/sfx/orc/miss/miss3.wav +0 -0
- package/examples/battle-benchmark-matterjs/assets/spritesheets/hero-atlas.json +246 -0
- package/examples/battle-benchmark-matterjs/assets/spritesheets/hero.png +0 -0
- package/examples/battle-benchmark-matterjs/assets/spritesheets/orc-atlas.json +246 -0
- package/examples/battle-benchmark-matterjs/assets/spritesheets/orc.png +0 -0
- package/examples/battle-benchmark-matterjs/assets/spritesheets/potion-atlas.json +68 -0
- package/examples/battle-benchmark-matterjs/assets/spritesheets/potion.png +0 -0
- package/examples/battle-benchmark-matterjs/dist/game.js +2 -0
- package/examples/battle-benchmark-matterjs/dist/game.js.LICENSE.txt +35 -0
- package/examples/battle-benchmark-matterjs/hud/damage-text.ts +46 -0
- package/examples/battle-benchmark-matterjs/hud/heal-text.ts +46 -0
- package/examples/battle-benchmark-matterjs/hud/hp-bar.ts +38 -0
- package/examples/battle-benchmark-matterjs/index.html +24 -0
- package/examples/battle-benchmark-matterjs/index.ts +41 -0
- package/examples/battle-benchmark-matterjs/objects/character.ts +95 -0
- package/examples/battle-benchmark-matterjs/objects/hero.ts +111 -0
- package/examples/battle-benchmark-matterjs/objects/orc.ts +107 -0
- package/examples/battle-benchmark-matterjs/objects/potion.ts +27 -0
- package/examples/battle-benchmark-matterjs/stage.ts +177 -0
- package/examples/battle-benchmark-separation/assets/bgm/battle.mp3 +0 -0
- package/examples/battle-benchmark-separation/assets/bitmap-fonts/white-peaberry.fnt +107 -0
- package/examples/battle-benchmark-separation/assets/bitmap-fonts/white-peaberry.png +0 -0
- package/examples/battle-benchmark-separation/assets/joystick/joystick.png +0 -0
- package/examples/battle-benchmark-separation/assets/joystick/knob.png +0 -0
- package/examples/battle-benchmark-separation/assets/sfx/hero/die/die.wav +0 -0
- package/examples/battle-benchmark-separation/assets/sfx/hero/heal/heal.wav +0 -0
- package/examples/battle-benchmark-separation/assets/sfx/hero/hit/hit1.wav +0 -0
- package/examples/battle-benchmark-separation/assets/sfx/hero/hit/hit2.wav +0 -0
- package/examples/battle-benchmark-separation/assets/sfx/hero/hit/hit3.wav +0 -0
- package/examples/battle-benchmark-separation/assets/sfx/hero/miss/miss1.wav +0 -0
- package/examples/battle-benchmark-separation/assets/sfx/hero/miss/miss2.wav +0 -0
- package/examples/battle-benchmark-separation/assets/sfx/hero/miss/miss3.wav +0 -0
- package/examples/battle-benchmark-separation/assets/sfx/orc/die/die.wav +0 -0
- package/examples/battle-benchmark-separation/assets/sfx/orc/hit/hit1.wav +0 -0
- package/examples/battle-benchmark-separation/assets/sfx/orc/hit/hit2.wav +0 -0
- package/examples/battle-benchmark-separation/assets/sfx/orc/hit/hit3.wav +0 -0
- package/examples/battle-benchmark-separation/assets/sfx/orc/miss/miss1.wav +0 -0
- package/examples/battle-benchmark-separation/assets/sfx/orc/miss/miss2.wav +0 -0
- package/examples/battle-benchmark-separation/assets/sfx/orc/miss/miss3.wav +0 -0
- package/examples/battle-benchmark-separation/assets/spritesheets/hero-atlas.json +246 -0
- package/examples/battle-benchmark-separation/assets/spritesheets/hero.png +0 -0
- package/examples/battle-benchmark-separation/assets/spritesheets/orc-atlas.json +246 -0
- package/examples/battle-benchmark-separation/assets/spritesheets/orc.png +0 -0
- package/examples/battle-benchmark-separation/assets/spritesheets/potion-atlas.json +68 -0
- package/examples/battle-benchmark-separation/assets/spritesheets/potion.png +0 -0
- package/examples/battle-benchmark-separation/dist/game.js +2 -0
- package/examples/battle-benchmark-separation/dist/game.js.LICENSE.txt +35 -0
- package/examples/battle-benchmark-separation/hud/damage-text.ts +46 -0
- package/examples/battle-benchmark-separation/hud/heal-text.ts +46 -0
- package/examples/battle-benchmark-separation/hud/hp-bar.ts +38 -0
- package/examples/battle-benchmark-separation/index.html +24 -0
- package/examples/battle-benchmark-separation/index.ts +41 -0
- package/examples/battle-benchmark-separation/objects/character.ts +225 -0
- package/examples/battle-benchmark-separation/objects/hero.ts +110 -0
- package/examples/battle-benchmark-separation/objects/orc.ts +213 -0
- package/examples/battle-benchmark-separation/objects/potion.ts +27 -0
- package/examples/battle-benchmark-separation/stage.ts +178 -0
- package/examples/battle-benchmark-separation2/assets/bgm/battle.mp3 +0 -0
- package/examples/battle-benchmark-separation2/assets/bitmap-fonts/white-peaberry.fnt +107 -0
- package/examples/battle-benchmark-separation2/assets/bitmap-fonts/white-peaberry.png +0 -0
- package/examples/battle-benchmark-separation2/assets/joystick/joystick.png +0 -0
- package/examples/battle-benchmark-separation2/assets/joystick/knob.png +0 -0
- package/examples/battle-benchmark-separation2/assets/sfx/hero/die/die.wav +0 -0
- package/examples/battle-benchmark-separation2/assets/sfx/hero/heal/heal.wav +0 -0
- package/examples/battle-benchmark-separation2/assets/sfx/hero/hit/hit1.wav +0 -0
- package/examples/battle-benchmark-separation2/assets/sfx/hero/hit/hit2.wav +0 -0
- package/examples/battle-benchmark-separation2/assets/sfx/hero/hit/hit3.wav +0 -0
- package/examples/battle-benchmark-separation2/assets/sfx/hero/miss/miss1.wav +0 -0
- package/examples/battle-benchmark-separation2/assets/sfx/hero/miss/miss2.wav +0 -0
- package/examples/battle-benchmark-separation2/assets/sfx/hero/miss/miss3.wav +0 -0
- package/examples/battle-benchmark-separation2/assets/sfx/orc/die/die.wav +0 -0
- package/examples/battle-benchmark-separation2/assets/sfx/orc/hit/hit1.wav +0 -0
- package/examples/battle-benchmark-separation2/assets/sfx/orc/hit/hit2.wav +0 -0
- package/examples/battle-benchmark-separation2/assets/sfx/orc/hit/hit3.wav +0 -0
- package/examples/battle-benchmark-separation2/assets/sfx/orc/miss/miss1.wav +0 -0
- package/examples/battle-benchmark-separation2/assets/sfx/orc/miss/miss2.wav +0 -0
- package/examples/battle-benchmark-separation2/assets/sfx/orc/miss/miss3.wav +0 -0
- package/examples/battle-benchmark-separation2/assets/spritesheets/hero-atlas.json +246 -0
- package/examples/battle-benchmark-separation2/assets/spritesheets/hero.png +0 -0
- package/examples/battle-benchmark-separation2/assets/spritesheets/orc-atlas.json +246 -0
- package/examples/battle-benchmark-separation2/assets/spritesheets/orc.png +0 -0
- package/examples/battle-benchmark-separation2/assets/spritesheets/potion-atlas.json +68 -0
- package/examples/battle-benchmark-separation2/assets/spritesheets/potion.png +0 -0
- package/examples/battle-benchmark-separation2/dist/game.js +2 -0
- package/examples/battle-benchmark-separation2/dist/game.js.LICENSE.txt +35 -0
- package/examples/battle-benchmark-separation2/hud/damage-text.ts +46 -0
- package/examples/battle-benchmark-separation2/hud/heal-text.ts +46 -0
- package/examples/battle-benchmark-separation2/hud/hp-bar.ts +38 -0
- package/examples/battle-benchmark-separation2/index.html +24 -0
- package/examples/battle-benchmark-separation2/index.ts +41 -0
- package/examples/battle-benchmark-separation2/objects/character.ts +195 -0
- package/examples/battle-benchmark-separation2/objects/hero.ts +110 -0
- package/examples/battle-benchmark-separation2/objects/orc.ts +213 -0
- package/examples/battle-benchmark-separation2/objects/potion.ts +27 -0
- package/examples/battle-benchmark-separation2/stage.ts +178 -0
- package/examples/collision-test/assets/cat.png +0 -0
- package/examples/collision-test/dist/game.js +2 -0
- package/examples/collision-test/dist/game.js.LICENSE.txt +35 -0
- package/examples/collision-test/index.html +24 -0
- package/examples/collision-test/index.ts +30 -0
- package/examples/dom-particle-test/assets/bird.png +0 -0
- package/examples/dom-particle-test/dist/game.js +2 -0
- package/examples/dom-particle-test/dist/game.js.LICENSE.txt +35 -0
- package/examples/dom-particle-test/index.html +24 -0
- package/examples/dom-particle-test/index.ts +27 -0
- package/examples/dom-sprite-test/assets/bird.png +0 -0
- package/examples/dom-sprite-test/assets/fire.png +0 -0
- package/examples/dom-sprite-test/assets/run.png +0 -0
- package/examples/dom-sprite-test/dist/game.js +2 -0
- package/examples/dom-sprite-test/dist/game.js.LICENSE.txt +35 -0
- package/examples/dom-sprite-test/index.html +24 -0
- package/examples/dom-sprite-test/index.ts +35 -0
- package/examples/dom-test/dist/game.js +2 -0
- package/examples/dom-test/dist/game.js.LICENSE.txt +35 -0
- package/examples/dom-test/index.html +24 -0
- package/examples/dom-test/index.ts +22 -0
- package/examples/particle-test/assets/bird.png +0 -0
- package/examples/particle-test/dist/game.js +2 -0
- package/examples/particle-test/dist/game.js.LICENSE.txt +35 -0
- package/examples/particle-test/index.html +24 -0
- package/examples/particle-test/index.ts +30 -0
- package/examples/renderer-test/dist/game.js +2 -0
- package/examples/renderer-test/dist/game.js.LICENSE.txt +35 -0
- package/examples/renderer-test/index.html +24 -0
- package/examples/renderer-test/index.ts +9 -0
- package/examples/simple-battle/assets/bgm/battle.mp3 +0 -0
- package/examples/simple-battle/assets/bitmap-fonts/white-peaberry.fnt +107 -0
- package/examples/simple-battle/assets/bitmap-fonts/white-peaberry.png +0 -0
- package/examples/simple-battle/assets/joystick/joystick.png +0 -0
- package/examples/simple-battle/assets/joystick/knob.png +0 -0
- package/examples/simple-battle/assets/sfx/hero/die/die.wav +0 -0
- package/examples/simple-battle/assets/sfx/hero/heal/heal.wav +0 -0
- package/examples/simple-battle/assets/sfx/hero/hit/hit1.wav +0 -0
- package/examples/simple-battle/assets/sfx/hero/hit/hit2.wav +0 -0
- package/examples/simple-battle/assets/sfx/hero/hit/hit3.wav +0 -0
- package/examples/simple-battle/assets/sfx/hero/miss/miss1.wav +0 -0
- package/examples/simple-battle/assets/sfx/hero/miss/miss2.wav +0 -0
- package/examples/simple-battle/assets/sfx/hero/miss/miss3.wav +0 -0
- package/examples/simple-battle/assets/sfx/orc/die/die.wav +0 -0
- package/examples/simple-battle/assets/sfx/orc/hit/hit1.wav +0 -0
- package/examples/simple-battle/assets/sfx/orc/hit/hit2.wav +0 -0
- package/examples/simple-battle/assets/sfx/orc/hit/hit3.wav +0 -0
- package/examples/simple-battle/assets/sfx/orc/miss/miss1.wav +0 -0
- package/examples/simple-battle/assets/sfx/orc/miss/miss2.wav +0 -0
- package/examples/simple-battle/assets/sfx/orc/miss/miss3.wav +0 -0
- package/examples/simple-battle/assets/spritesheets/hero-atlas.json +246 -0
- package/examples/simple-battle/assets/spritesheets/hero.png +0 -0
- package/examples/simple-battle/assets/spritesheets/orc-atlas.json +246 -0
- package/examples/simple-battle/assets/spritesheets/orc.png +0 -0
- package/examples/simple-battle/assets/spritesheets/potion-atlas.json +68 -0
- package/examples/simple-battle/assets/spritesheets/potion.png +0 -0
- package/examples/simple-battle/dist/game.js +2 -0
- package/examples/simple-battle/dist/game.js.LICENSE.txt +35 -0
- package/examples/simple-battle/hud/damage-text.ts +46 -0
- package/examples/simple-battle/hud/heal-text.ts +46 -0
- package/examples/simple-battle/hud/hp-bar.ts +38 -0
- package/examples/simple-battle/index.html +24 -0
- package/examples/simple-battle/index.ts +41 -0
- package/examples/simple-battle/objects/character.ts +95 -0
- package/examples/simple-battle/objects/hero.ts +111 -0
- package/examples/simple-battle/objects/orc.ts +107 -0
- package/examples/simple-battle/objects/potion.ts +27 -0
- package/examples/simple-battle/stage.ts +174 -0
- package/examples/spine-test/assets/spine/spineboy.atlas +95 -0
- package/examples/spine-test/assets/spine/spineboy.png +0 -0
- package/examples/spine-test/assets/spine/spineboy.skel +0 -0
- package/examples/spine-test/dist/game.js +2 -0
- package/examples/spine-test/dist/game.js.LICENSE.txt +35 -0
- package/examples/spine-test/index.html +24 -0
- package/examples/spine-test/index.ts +29 -0
- package/examples/sprite-test/assets/bird.png +0 -0
- package/examples/sprite-test/assets/fire.png +0 -0
- package/examples/sprite-test/dist/game.js +2 -0
- package/examples/sprite-test/dist/game.js.LICENSE.txt +35 -0
- package/examples/sprite-test/index.html +24 -0
- package/examples/sprite-test/index.ts +38 -0
- package/examples/tsconfig.json +2 -1
- package/examples/webpack.config.js +17 -3
- package/jest.config.ts +10 -0
- package/lib/asset/audio.js +47 -11
- package/lib/asset/audio.js.map +1 -1
- package/lib/asset/loaders/audio.js +7 -4
- package/lib/asset/loaders/audio.js.map +1 -1
- package/lib/asset/loaders/binary.js +7 -4
- package/lib/asset/loaders/binary.js.map +1 -1
- package/lib/asset/loaders/bitmap-font.js +74 -0
- package/lib/asset/loaders/bitmap-font.js.map +1 -0
- package/lib/asset/loaders/font.js +4 -1
- package/lib/asset/loaders/font.js.map +1 -1
- package/lib/asset/loaders/loader.js +17 -12
- package/lib/asset/loaders/loader.js.map +1 -1
- package/lib/asset/loaders/spritesheet.js +18 -8
- package/lib/asset/loaders/spritesheet.js.map +1 -1
- package/lib/asset/loaders/text.js +6 -3
- package/lib/asset/loaders/text.js.map +1 -1
- package/lib/asset/loaders/texture.js +22 -26
- package/lib/asset/loaders/texture.js.map +1 -1
- package/lib/asset/preload.js +60 -56
- package/lib/asset/preload.js.map +1 -1
- package/lib/collision/check-collision.js +804 -0
- package/lib/collision/check-collision.js.map +1 -0
- package/lib/collision/check-collision.test.js +300 -0
- package/lib/collision/check-collision.test.js.map +1 -0
- package/lib/collision/colliders.js +8 -0
- package/lib/collision/colliders.js.map +1 -0
- package/lib/debug.js.map +1 -0
- package/lib/dom/dom-animated-sprite.js +106 -0
- package/lib/dom/dom-animated-sprite.js.map +1 -0
- package/lib/dom/dom-game-object.js +108 -0
- package/lib/dom/dom-game-object.js.map +1 -0
- package/lib/dom/dom-particle.js +105 -0
- package/lib/dom/dom-particle.js.map +1 -0
- package/lib/dom/dom-preload.js +43 -0
- package/lib/dom/dom-preload.js.map +1 -0
- package/lib/dom/dom-sprite.js +40 -0
- package/lib/dom/dom-sprite.js.map +1 -0
- package/lib/dom/dom-texture-loader.js +36 -0
- package/lib/dom/dom-texture-loader.js.map +1 -0
- package/lib/dom/dom-utils.js +20 -0
- package/lib/dom/dom-utils.js.map +1 -0
- package/lib/index copy.js +16 -0
- package/lib/index copy.js.map +1 -0
- package/lib/index.js +36 -10
- package/lib/index.js.map +1 -1
- package/lib/input/joystick.js +262 -0
- package/lib/input/joystick.js.map +1 -0
- package/lib/node/core/dirty-number.js +19 -0
- package/lib/node/core/dirty-number.js.map +1 -0
- package/lib/node/core/game-node.js +63 -0
- package/lib/node/core/game-node.js.map +1 -0
- package/lib/node/core/game-object.js +8 -0
- package/lib/node/core/game-object.js.map +1 -0
- package/lib/node/core/renderable.js +59 -0
- package/lib/node/core/renderable.js.map +1 -0
- package/lib/node/core/transform.js +70 -0
- package/lib/node/core/transform.js.map +1 -0
- package/lib/node/core/transformable.js +85 -0
- package/lib/node/core/transformable.js.map +1 -0
- package/lib/node/ext/animated-sprite.js +77 -0
- package/lib/node/ext/animated-sprite.js.map +1 -0
- package/lib/node/ext/bitmap-text.js +93 -0
- package/lib/node/ext/bitmap-text.js.map +1 -0
- package/lib/node/ext/circle.js +43 -0
- package/lib/node/ext/circle.js.map +1 -0
- package/lib/node/ext/deplay.js +22 -0
- package/lib/node/ext/deplay.js.map +1 -0
- package/lib/node/ext/dom-container.js +51 -0
- package/lib/node/ext/dom-container.js.map +1 -0
- package/lib/node/ext/interval.js +22 -0
- package/lib/node/ext/interval.js.map +1 -0
- package/lib/node/ext/particle.js +98 -0
- package/lib/node/ext/particle.js.map +1 -0
- package/lib/node/ext/rectangle.js +52 -0
- package/lib/node/ext/rectangle.js.map +1 -0
- package/lib/node/ext/spine.js +272 -0
- package/lib/node/ext/spine.js.map +1 -0
- package/lib/node/ext/sprite.js +42 -0
- package/lib/node/ext/sprite.js.map +1 -0
- package/lib/node/physics/physics-object.js +92 -0
- package/lib/node/physics/physics-object.js.map +1 -0
- package/lib/node/physics/physics-world.js +29 -0
- package/lib/node/physics/physics-world.js.map +1 -0
- package/lib/node/physics/rigidbodies.js +7 -0
- package/lib/node/physics/rigidbodies.js.map +1 -0
- package/lib/renderer/camera.js +19 -0
- package/lib/renderer/camera.js.map +1 -0
- package/lib/renderer/container-manager.js +29 -0
- package/lib/renderer/container-manager.js.map +1 -0
- package/lib/renderer/fps-display.js +18 -0
- package/lib/renderer/fps-display.js.map +1 -0
- package/lib/renderer/layer.js +12 -0
- package/lib/renderer/layer.js.map +1 -0
- package/lib/renderer/renderer.js +146 -0
- package/lib/renderer/renderer.js.map +1 -0
- package/lib/renderer/ticker.js +56 -0
- package/lib/renderer/ticker.js.map +1 -0
- package/lib/renderer/ticker.test.js +241 -0
- package/lib/renderer/ticker.test.js.map +1 -0
- package/lib/types/animation-atlas.js +2 -0
- package/lib/types/animation-atlas.js.map +1 -0
- package/lib/types/asset/audio.d.ts +5 -4
- package/lib/types/asset/audio.d.ts.map +1 -1
- package/lib/types/asset/loaders/audio.d.ts +2 -1
- package/lib/types/asset/loaders/audio.d.ts.map +1 -1
- package/lib/types/asset/loaders/binary.d.ts +2 -1
- package/lib/types/asset/loaders/binary.d.ts.map +1 -1
- package/lib/types/asset/loaders/bitmap-font.d.ts +17 -0
- package/lib/types/asset/loaders/bitmap-font.d.ts.map +1 -0
- package/lib/types/asset/loaders/font.d.ts +2 -1
- package/lib/types/asset/loaders/font.d.ts.map +1 -1
- package/lib/types/asset/loaders/loader.d.ts +6 -6
- package/lib/types/asset/loaders/loader.d.ts.map +1 -1
- package/lib/types/asset/loaders/spritesheet.d.ts +14 -6
- package/lib/types/asset/loaders/spritesheet.d.ts.map +1 -1
- package/lib/types/asset/loaders/text.d.ts +2 -1
- package/lib/types/asset/loaders/text.d.ts.map +1 -1
- package/lib/types/asset/loaders/texture.d.ts +2 -2
- package/lib/types/asset/loaders/texture.d.ts.map +1 -1
- package/lib/types/asset/preload.d.ts +7 -5
- package/lib/types/asset/preload.d.ts.map +1 -1
- package/lib/types/atlas copy.js +2 -0
- package/lib/types/atlas copy.js.map +1 -0
- package/lib/types/atlas.js +2 -0
- package/lib/types/atlas.js.map +1 -0
- package/lib/types/bitmap-font.js +2 -0
- package/lib/types/bitmap-font.js.map +1 -0
- package/lib/types/collision/check-collision.d.ts +4 -0
- package/lib/types/collision/check-collision.d.ts.map +1 -0
- package/lib/types/collision/check-collision.test.d.ts +2 -0
- package/lib/types/collision/check-collision.test.d.ts.map +1 -0
- package/lib/types/collision/colliders.d.ts +34 -0
- package/lib/types/collision/colliders.d.ts.map +1 -0
- package/lib/types/debug.d.ts.map +1 -0
- package/lib/types/dom/dom-animated-sprite.d.ts +23 -0
- package/lib/types/dom/dom-animated-sprite.d.ts.map +1 -0
- package/lib/types/dom/dom-game-object.d.ts +44 -0
- package/lib/types/dom/dom-game-object.d.ts.map +1 -0
- package/lib/types/dom/dom-particle.d.ts +30 -0
- package/lib/types/dom/dom-particle.d.ts.map +1 -0
- package/lib/types/dom/dom-preload.d.ts +2 -0
- package/lib/types/dom/dom-preload.d.ts.map +1 -0
- package/lib/types/dom/dom-sprite.d.ts +13 -0
- package/lib/types/dom/dom-sprite.d.ts.map +1 -0
- package/lib/types/dom/dom-texture-loader.d.ts +8 -0
- package/lib/types/dom/dom-texture-loader.d.ts.map +1 -0
- package/lib/types/dom/dom-utils.d.ts +3 -0
- package/lib/types/dom/dom-utils.d.ts.map +1 -0
- package/lib/types/index copy.d.ts +16 -0
- package/lib/types/index copy.d.ts.map +1 -0
- package/lib/types/index.d.ts +26 -11
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/input/joystick.d.ts +28 -0
- package/lib/types/input/joystick.d.ts.map +1 -0
- package/lib/types/node/core/dirty-number.d.ts +9 -0
- package/lib/types/node/core/dirty-number.d.ts.map +1 -0
- package/lib/types/node/core/game-node.d.ts +16 -0
- package/lib/types/node/core/game-node.d.ts.map +1 -0
- package/lib/types/node/core/game-object.d.ts +8 -0
- package/lib/types/node/core/game-object.d.ts.map +1 -0
- package/lib/types/node/core/renderable.d.ts +23 -0
- package/lib/types/node/core/renderable.d.ts.map +1 -0
- package/lib/types/node/core/transform.d.ts +27 -0
- package/lib/types/node/core/transform.d.ts.map +1 -0
- package/lib/types/node/core/transformable.d.ts +44 -0
- package/lib/types/node/core/transformable.d.ts.map +1 -0
- package/lib/types/node/ext/animated-sprite.d.ts +22 -0
- package/lib/types/node/ext/animated-sprite.d.ts.map +1 -0
- package/lib/types/node/ext/bitmap-text.d.ts +14 -0
- package/lib/types/node/ext/bitmap-text.d.ts.map +1 -0
- package/lib/types/node/ext/circle.d.ts +19 -0
- package/lib/types/node/ext/circle.d.ts.map +1 -0
- package/lib/types/node/ext/deplay.d.ts +8 -0
- package/lib/types/node/ext/deplay.d.ts.map +1 -0
- package/lib/types/node/ext/dom-container.d.ts +12 -0
- package/lib/types/node/ext/dom-container.d.ts.map +1 -0
- package/lib/types/node/ext/interval.d.ts +9 -0
- package/lib/types/node/ext/interval.d.ts.map +1 -0
- package/lib/types/node/ext/particle.d.ts +30 -0
- package/lib/types/node/ext/particle.d.ts.map +1 -0
- package/lib/types/node/ext/rectangle.d.ts +22 -0
- package/lib/types/node/ext/rectangle.d.ts.map +1 -0
- package/lib/types/node/ext/spine.d.ts +36 -0
- package/lib/types/node/ext/spine.d.ts.map +1 -0
- package/lib/types/node/ext/sprite.d.ts +13 -0
- package/lib/types/node/ext/sprite.d.ts.map +1 -0
- package/lib/types/node/physics/physics-object.d.ts +38 -0
- package/lib/types/node/physics/physics-object.d.ts.map +1 -0
- package/lib/types/node/physics/physics-world.d.ts +18 -0
- package/lib/types/node/physics/physics-world.d.ts.map +1 -0
- package/lib/types/node/physics/rigidbodies.d.ts +23 -0
- package/lib/types/node/physics/rigidbodies.d.ts.map +1 -0
- package/lib/types/renderer/camera.d.ts +13 -0
- package/lib/types/renderer/camera.d.ts.map +1 -0
- package/lib/types/renderer/container-manager.d.ts +9 -0
- package/lib/types/renderer/container-manager.d.ts.map +1 -0
- package/lib/types/renderer/fps-display.d.ts +7 -0
- package/lib/types/renderer/fps-display.d.ts.map +1 -0
- package/lib/types/renderer/layer.d.ts +7 -0
- package/lib/types/renderer/layer.d.ts.map +1 -0
- package/lib/types/renderer/renderer.d.ts +40 -0
- package/lib/types/renderer/renderer.d.ts.map +1 -0
- package/lib/types/renderer/ticker.d.ts +6 -0
- package/lib/types/renderer/ticker.d.ts.map +1 -0
- package/lib/types/renderer/ticker.test.d.ts +40 -0
- package/lib/types/renderer/ticker.test.d.ts.map +1 -0
- package/lib/types/sprite-atlas.js +2 -0
- package/lib/types/sprite-atlas.js.map +1 -0
- package/lib/types/types/animation-atlas.d.ts +14 -0
- package/lib/types/types/animation-atlas.d.ts.map +1 -0
- package/lib/types/types/atlas copy.d.ts +12 -0
- package/lib/types/types/atlas copy.d.ts.map +1 -0
- package/lib/types/types/atlas.d.ts +16 -0
- package/lib/types/types/atlas.d.ts.map +1 -0
- package/lib/types/types/bitmap-font.d.ts +18 -0
- package/lib/types/types/bitmap-font.d.ts.map +1 -0
- package/lib/types/types/sprite-atlas.d.ts +13 -0
- package/lib/types/types/sprite-atlas.d.ts.map +1 -0
- package/lib/types/utils/device.d.ts +2 -0
- package/lib/types/utils/device.d.ts.map +1 -0
- package/lib/utils/device.js +2 -0
- package/lib/utils/device.js.map +1 -0
- package/package.json +8 -7
- package/src/asset/audio.ts +134 -90
- package/src/asset/loaders/audio.ts +23 -20
- package/src/asset/loaders/binary.ts +20 -16
- package/src/asset/loaders/bitmap-font.ts +91 -0
- package/src/asset/loaders/font.ts +18 -14
- package/src/asset/loaders/loader.ts +27 -23
- package/src/asset/loaders/spritesheet.ts +47 -36
- package/src/asset/loaders/text.ts +19 -15
- package/src/asset/loaders/texture.ts +30 -37
- package/src/asset/preload.ts +71 -64
- package/src/collision/check-collision.test.ts +349 -0
- package/src/collision/check-collision.ts +821 -0
- package/src/collision/colliders.ts +19 -0
- package/src/debug.ts +5 -0
- package/src/dom/dom-animated-sprite.ts +132 -0
- package/src/dom/dom-game-object.ts +134 -0
- package/src/dom/dom-particle.ts +151 -0
- package/src/dom/dom-preload.ts +54 -0
- package/src/dom/dom-sprite.ts +50 -0
- package/src/dom/dom-texture-loader.ts +44 -0
- package/src/dom/dom-utils.ts +19 -0
- package/src/index.ts +47 -13
- package/src/input/joystick.ts +316 -0
- package/src/node/core/dirty-number.ts +21 -0
- package/src/node/core/game-node.ts +74 -0
- package/src/node/core/game-object.ts +11 -0
- package/src/node/core/renderable.ts +72 -0
- package/src/node/core/transform.ts +82 -0
- package/src/node/core/transformable.ts +111 -0
- package/src/node/ext/animated-sprite.ts +103 -0
- package/src/node/ext/bitmap-text.ts +113 -0
- package/src/node/ext/circle.ts +55 -0
- package/src/node/ext/deplay.ts +25 -0
- package/src/node/ext/dom-container.ts +62 -0
- package/src/node/ext/interval.ts +25 -0
- package/src/node/ext/particle.ts +142 -0
- package/src/node/ext/rectangle.ts +71 -0
- package/src/node/ext/spine.ts +323 -0
- package/src/node/ext/sprite.ts +53 -0
- package/src/node/physics/physics-object.ts +127 -0
- package/src/node/physics/physics-world.ts +41 -0
- package/src/node/physics/rigidbodies.ts +14 -0
- package/src/renderer/camera.ts +25 -0
- package/src/renderer/container-manager.ts +36 -0
- package/src/renderer/fps-display.ts +21 -0
- package/src/renderer/layer.ts +15 -0
- package/src/renderer/renderer.ts +181 -0
- package/src/renderer/ticker.test.ts +325 -0
- package/src/renderer/ticker.ts +54 -0
- package/src/types/atlas.ts +17 -0
- package/src/types/bitmap-font.ts +19 -0
- package/src/utils/device.ts +1 -0
- package/examples/test-dom/index.ts +0 -21
- package/lib/game-object/game-object-physics.js +0 -188
- package/lib/game-object/game-object-physics.js.map +0 -1
- package/lib/game-object/game-object-rendering.js +0 -35
- package/lib/game-object/game-object-rendering.js.map +0 -1
- package/lib/game-object/game-object.js +0 -162
- package/lib/game-object/game-object.js.map +0 -1
- package/lib/game-object/transform.js +0 -118
- package/lib/game-object/transform.js.map +0 -1
- package/lib/game-object-ext/animated-sprite.js +0 -117
- package/lib/game-object-ext/animated-sprite.js.map +0 -1
- package/lib/game-object-ext/dom-container.js +0 -56
- package/lib/game-object-ext/dom-container.js.map +0 -1
- package/lib/game-object-ext/rect.js +0 -30
- package/lib/game-object-ext/rect.js.map +0 -1
- package/lib/game-object-ext/spine.js +0 -206
- package/lib/game-object-ext/spine.js.map +0 -1
- package/lib/game-object-ext/sprite.js +0 -46
- package/lib/game-object-ext/sprite.js.map +0 -1
- package/lib/game-object-ext/text.js +0 -68
- package/lib/game-object-ext/text.js.map +0 -1
- package/lib/game-object-ext/tiling-sprite.js +0 -64
- package/lib/game-object-ext/tiling-sprite.js.map +0 -1
- package/lib/types/game-object/game-object-physics.d.ts +0 -42
- package/lib/types/game-object/game-object-physics.d.ts.map +0 -1
- package/lib/types/game-object/game-object-rendering.d.ts +0 -15
- package/lib/types/game-object/game-object-rendering.d.ts.map +0 -1
- package/lib/types/game-object/game-object.d.ts +0 -81
- package/lib/types/game-object/game-object.d.ts.map +0 -1
- package/lib/types/game-object/transform.d.ts +0 -43
- package/lib/types/game-object/transform.d.ts.map +0 -1
- package/lib/types/game-object-ext/animated-sprite.d.ts +0 -29
- package/lib/types/game-object-ext/animated-sprite.d.ts.map +0 -1
- package/lib/types/game-object-ext/dom-container.d.ts +0 -16
- package/lib/types/game-object-ext/dom-container.d.ts.map +0 -1
- package/lib/types/game-object-ext/rect.d.ts +0 -17
- package/lib/types/game-object-ext/rect.d.ts.map +0 -1
- package/lib/types/game-object-ext/spine.d.ts +0 -35
- package/lib/types/game-object-ext/spine.d.ts.map +0 -1
- package/lib/types/game-object-ext/sprite.d.ts +0 -14
- package/lib/types/game-object-ext/sprite.d.ts.map +0 -1
- package/lib/types/game-object-ext/text.d.ts +0 -26
- package/lib/types/game-object-ext/text.d.ts.map +0 -1
- package/lib/types/game-object-ext/tiling-sprite.d.ts +0 -20
- package/lib/types/game-object-ext/tiling-sprite.d.ts.map +0 -1
- package/lib/types/utils/debug.d.ts.map +0 -1
- package/lib/types/utils/go.d.ts +0 -26
- package/lib/types/utils/go.d.ts.map +0 -1
- package/lib/types/world/world-debug.d.ts +0 -11
- package/lib/types/world/world-debug.d.ts.map +0 -1
- package/lib/types/world/world-physics.d.ts +0 -16
- package/lib/types/world/world-physics.d.ts.map +0 -1
- package/lib/types/world/world-rendering.d.ts +0 -28
- package/lib/types/world/world-rendering.d.ts.map +0 -1
- package/lib/types/world/world.d.ts +0 -38
- package/lib/types/world/world.d.ts.map +0 -1
- package/lib/utils/debug.js.map +0 -1
- package/lib/utils/go.js +0 -33
- package/lib/utils/go.js.map +0 -1
- package/lib/world/world-debug.js +0 -89
- package/lib/world/world-debug.js.map +0 -1
- package/lib/world/world-physics.js +0 -45
- package/lib/world/world-physics.js.map +0 -1
- package/lib/world/world-rendering.js +0 -123
- package/lib/world/world-rendering.js.map +0 -1
- package/lib/world/world.js +0 -147
- package/lib/world/world.js.map +0 -1
- package/src/game-object/game-object-physics.ts +0 -191
- package/src/game-object/game-object-rendering.ts +0 -27
- package/src/game-object/game-object.ts +0 -190
- package/src/game-object/transform.ts +0 -164
- package/src/game-object-ext/animated-sprite.ts +0 -140
- package/src/game-object-ext/dom-container.ts +0 -67
- package/src/game-object-ext/rect.ts +0 -40
- package/src/game-object-ext/spine.ts +0 -235
- package/src/game-object-ext/sprite.ts +0 -55
- package/src/game-object-ext/text.ts +0 -83
- package/src/game-object-ext/tiling-sprite.ts +0 -73
- package/src/utils/debug.ts +0 -5
- package/src/utils/go.ts +0 -53
- package/src/world/world-debug.ts +0 -114
- package/src/world/world-physics.ts +0 -52
- package/src/world/world-rendering.ts +0 -145
- package/src/world/world.ts +0 -171
- /package/examples/{test-dom → auto-battle}/index.html +0 -0
- /package/lib/{utils/debug.js → debug.js} +0 -0
- /package/lib/types/{utils/debug.d.ts → debug.d.ts} +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
|
+
}
|