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
package/README.md
CHANGED
|
@@ -1,8 +1,579 @@
|
|
|
1
1
|
# Kiwi Engine
|
|
2
|
-
TypeScript 기반 2D 웹 게임 엔진입니다.
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
**Kiwi Engine** is a **TypeScript-based 2D web game engine**.
|
|
4
|
+
|
|
5
|
+
* **Center-origin coordinates**: `(0, 0)` is always the **center of the canvas** (not the top-left).
|
|
6
|
+
* **Responsive canvas**: the canvas **matches its parent element’s size** and resizes when the parent changes (e.g., `body` → full-window games).
|
|
7
|
+
* Built for **time-based updates**, mobile/desktop input, and both **Canvas** and **DOM-based** rendering nodes.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Coordinate System
|
|
12
|
+
|
|
13
|
+
Most 2D engines use `(0, 0)` at the top-left. Kiwi flips that: the center of the canvas is `(0, 0)`.
|
|
14
|
+
This makes layout and UI easier on the web’s fluid screens.
|
|
15
|
+
|
|
16
|
+
* Top-left is `(-width/2, -height/2)`, bottom-right is `(width/2, height/2)`.
|
|
17
|
+
* Use `Renderer.screenToWorld(x, y)` to convert browser (screen) coordinates to **world** coordinates.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Canvas Size
|
|
22
|
+
|
|
23
|
+
The canvas always **matches its parent element**. If the parent resizes, the canvas follows.
|
|
24
|
+
If the parent is `document.body` and the body fills the window, the canvas will also fill the window and resize on window changes.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## API
|
|
29
|
+
|
|
30
|
+
### Ticker (Game Loop)
|
|
31
|
+
|
|
32
|
+
`Ticker` is a **`requestAnimationFrame`-based loop manager**. It calls your `onTick(dt)` each frame so you can do **time-based updates**.
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { Ticker } from 'kiwiengine'
|
|
36
|
+
|
|
37
|
+
// dt = seconds since the previous tick (≈ 0.0167 at 60 FPS)
|
|
38
|
+
const speed = 120
|
|
39
|
+
const ticker = new Ticker((dt) => {
|
|
40
|
+
player.x += speed * dt
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
// When done, clean up:
|
|
44
|
+
ticker.remove()
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
#### Constructor
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
new Ticker(onTick: (dt: number) => void)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
* `dt` is in **seconds** and is valid even on the first frame.
|
|
54
|
+
* Called **once or more per frame** depending on internal catch-up behavior (see below).
|
|
55
|
+
|
|
56
|
+
#### Fixed Step & FPS Cap (Debug-only)
|
|
57
|
+
|
|
58
|
+
When **`debugMode`** is enabled and the browser tab is **unfocused or inactive**:
|
|
59
|
+
|
|
60
|
+
* The loop is **capped at 6 FPS** to save CPU/GPU.
|
|
61
|
+
* The loop switches to a **fixed step**:
|
|
62
|
+
|
|
63
|
+
* Step size: `1 / fpsCap` (default: `1/6 ≈ 0.1667s`).
|
|
64
|
+
* If accumulated lag exceeds one step, `onTick()` runs once with the **fixed step**.
|
|
65
|
+
* If lag is **≥ 2×** the step, an **extra** `onTick()` runs with the **accumulated dt** to catch up.
|
|
66
|
+
* When the tab regains focus, the cap is lifted and the loop returns to normal rAF.
|
|
67
|
+
* On **`pageshow`** (e.g., returning from bfcache), the cap/lag state is reset and the normal loop resumes.
|
|
68
|
+
|
|
69
|
+
> `fpsCap` is internal; you don’t set it. It only activates in **debug mode** when the page is **not focused**.
|
|
70
|
+
|
|
71
|
+
#### Lifecycle
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
Ticker#remove(): void
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
* Stops the loop and removes focus/blur/page listeners.
|
|
78
|
+
* `Renderer.remove()` will also remove its internal `Ticker`.
|
|
79
|
+
|
|
80
|
+
#### Tips
|
|
81
|
+
|
|
82
|
+
* **Prefer time-based updates** (multiply by `dt`) for physics/movement/animation:
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
velocity.y += GRAVITY * dt
|
|
86
|
+
position.x += velocity.x * dt
|
|
87
|
+
```
|
|
88
|
+
* **Avoid double loops**: if your `Renderer` is already driving a frame loop, use its **update hooks** (e.g., `GameObject.update`) instead of starting another `Ticker`.
|
|
89
|
+
* **Always clean up**: call `remove()` on scene changes or unmount to prevent leaks.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Renderer
|
|
94
|
+
|
|
95
|
+
`Renderer` manages **drawing**, **camera**, **layers**, **resizing**, and its **render loop** (internally powered by `Ticker`).
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
import { Renderer } from 'kiwiengine'
|
|
99
|
+
|
|
100
|
+
const renderer = new Renderer(document.body, {
|
|
101
|
+
layers: [
|
|
102
|
+
{ name: 'background', drawOrder: 0 },
|
|
103
|
+
{ name: 'game', drawOrder: 1 },
|
|
104
|
+
{ name: 'ui', drawOrder: 2 },
|
|
105
|
+
],
|
|
106
|
+
logicalWidth: 1920,
|
|
107
|
+
logicalHeight: 1080,
|
|
108
|
+
backgroundColor: 0x000000,
|
|
109
|
+
})
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Key Features
|
|
113
|
+
|
|
114
|
+
* **Layer system**: Define named layers with draw order; each `GameObject` chooses its `layer`.
|
|
115
|
+
* **Auto-resize**: Canvas follows parent size; transforms stay center-origin.
|
|
116
|
+
* **Camera**: Pan and zoom via `Renderer.camera`.
|
|
117
|
+
* **FPS display (debug)**: Shown when `debugMode` is on.
|
|
118
|
+
* **Screen → World conversion**: `screenToWorld(x, y)` converts `clientX/Y` into world space.
|
|
119
|
+
* **Loop management**: Uses `Ticker`; in debug mode, inherits the **6 FPS cap** on unfocused tabs.
|
|
120
|
+
|
|
121
|
+
### Options (`RendererOptions`)
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
type RendererOptions = {
|
|
125
|
+
logicalWidth?: number
|
|
126
|
+
logicalHeight?: number
|
|
127
|
+
backgroundColor?: ColorSource
|
|
128
|
+
backgroundAlpha?: number
|
|
129
|
+
layers?: { name: string; drawOrder: number }[]
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
* `logicalWidth/Height`: Set a **logical resolution**; the renderer scales proportionally to the screen.
|
|
134
|
+
|
|
135
|
+
### Methods
|
|
136
|
+
|
|
137
|
+
#### `screenToWorld(x: number, y: number): { x: number, y: number }`
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
const worldPos = renderer.screenToWorld(event.clientX, event.clientY)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
#### `remove(): void`
|
|
144
|
+
|
|
145
|
+
Tears down the renderer, its **Ticker**, canvas, FPS overlay, and DOM bindings.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## GameObject
|
|
150
|
+
|
|
151
|
+
`GameObject` is the basic renderable node with **position/rotation/scale**, optional **children**, and **layer**.
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import { GameObject } from 'kiwiengine'
|
|
155
|
+
|
|
156
|
+
const player = new GameObject({
|
|
157
|
+
x: 0,
|
|
158
|
+
y: 0,
|
|
159
|
+
scale: 1,
|
|
160
|
+
rotation: 0,
|
|
161
|
+
layer: 'game',
|
|
162
|
+
useYSort: true, // draw in front if y is larger
|
|
163
|
+
alpha: 1,
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
root.add(player)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### `GameObjectOptions`
|
|
170
|
+
|
|
171
|
+
* `x`, `y`: local position.
|
|
172
|
+
* `scale`, `scaleX`, `scaleY`: scaling.
|
|
173
|
+
* `pivotX`, `pivotY`: pivot for rotation/scale.
|
|
174
|
+
* `rotation`: radians.
|
|
175
|
+
* `alpha`: 0–1.
|
|
176
|
+
* `layer`: target layer name.
|
|
177
|
+
* `useYSort`: if `true`, container `drawOrder` follows current `y`.
|
|
178
|
+
|
|
179
|
+
### Children & Control
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
const parent = new GameObject({ x: -100, y: 0, layer: 'game' })
|
|
183
|
+
const child = new GameObject({ x: 50, y: 0 })
|
|
184
|
+
|
|
185
|
+
parent.add(child) // parent transforms propagate
|
|
186
|
+
root.add(parent)
|
|
187
|
+
|
|
188
|
+
// Lifecycle helpers:
|
|
189
|
+
parent.pause()
|
|
190
|
+
parent.resume()
|
|
191
|
+
parent.remove() // removes self and all descendants
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Y-Sorting Example
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
const a = new GameObject({ y: -50, useYSort: true })
|
|
198
|
+
const b = new GameObject({ y: 30, useYSort: true })
|
|
199
|
+
// If both share the same parent, b renders in front of a.
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Assets
|
|
205
|
+
|
|
206
|
+
### `preload(assets, progressCallback?) => () => void`
|
|
207
|
+
|
|
208
|
+
Preload textures/audio/fonts/spritesheets. Returns a **release** function to clear the cache.
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
import { preload } from 'kiwiengine'
|
|
212
|
+
|
|
213
|
+
const release = await preload(
|
|
214
|
+
[
|
|
215
|
+
'assets/player.png',
|
|
216
|
+
{ src: 'assets/atlas.png', atlas: atlasJson },
|
|
217
|
+
{ fnt: 'myFont', src: 'assets/myFont.fnt' },
|
|
218
|
+
'assets/bgm.mp3',
|
|
219
|
+
],
|
|
220
|
+
(p) => console.log(`loading: ${(p * 100) | 0}%`)
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
// later, when no longer needed:
|
|
224
|
+
release()
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### `musicPlayer` (BGM)
|
|
228
|
+
|
|
229
|
+
Simple background-music player. Volume is persisted in `localStorage`.
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
import { musicPlayer } from 'kiwiengine'
|
|
233
|
+
|
|
234
|
+
musicPlayer.volume = 0.5 // 0..1
|
|
235
|
+
musicPlayer.play('bgm.mp3') // reusing same src won’t duplicate
|
|
236
|
+
musicPlayer.pause()
|
|
237
|
+
musicPlayer.stop()
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### `sfxPlayer` (SFX)
|
|
241
|
+
|
|
242
|
+
One-shot, lightweight effect playback. Volume persisted in `localStorage`.
|
|
243
|
+
|
|
244
|
+
```ts
|
|
245
|
+
import { sfxPlayer } from 'kiwiengine'
|
|
246
|
+
|
|
247
|
+
sfxPlayer.volume = 0.8
|
|
248
|
+
sfxPlayer.play('click.wav')
|
|
249
|
+
sfxPlayer.playRandom('hit1.ogg', 'hit2.ogg', 'hit3.ogg')
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Collision
|
|
255
|
+
|
|
256
|
+
### Collider Types
|
|
257
|
+
|
|
258
|
+
```ts
|
|
259
|
+
import {
|
|
260
|
+
ColliderType,
|
|
261
|
+
type RectangleCollider, type CircleCollider,
|
|
262
|
+
type EllipseCollider, type PolygonCollider,
|
|
263
|
+
type Collider
|
|
264
|
+
} from 'kiwiengine'
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
* `RectangleCollider`: `{ type: Rectangle, width, height, x?, y? }`
|
|
268
|
+
* `CircleCollider`: `{ type: Circle, radius, x?, y? }`
|
|
269
|
+
* `EllipseCollider`: `{ type: Ellipse, width, height, x?, y? }`
|
|
270
|
+
* `PolygonCollider`: `{ type: Polygon, vertices: {x,y}[], x?, y? }`
|
|
271
|
+
|
|
272
|
+
### `checkCollision(ca, ta, cb, tb): boolean`
|
|
273
|
+
|
|
274
|
+
Generic collision test between rectangles/circles/ellipses/polygons.
|
|
275
|
+
`ta/tb` are the **world transforms** (position/rotation/scale) for each collider.
|
|
276
|
+
|
|
277
|
+
```ts
|
|
278
|
+
import { checkCollision } from 'kiwiengine'
|
|
279
|
+
|
|
280
|
+
const hit = checkCollision(colA, worldTransformA, colB, worldTransformB)
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
## Built-in Nodes & Extensions
|
|
286
|
+
|
|
287
|
+
### `AnimatedSpriteNode`
|
|
288
|
+
|
|
289
|
+
Spritesheet animation.
|
|
290
|
+
|
|
291
|
+
```ts
|
|
292
|
+
import { AnimatedSpriteNode } from 'kiwiengine'
|
|
293
|
+
|
|
294
|
+
const run = new AnimatedSpriteNode({
|
|
295
|
+
src: 'atlas.png',
|
|
296
|
+
atlas: atlasJson,
|
|
297
|
+
animation: 'run',
|
|
298
|
+
fps: 12,
|
|
299
|
+
loop: true,
|
|
300
|
+
x: 0, y: 0, layer: 'game',
|
|
301
|
+
})
|
|
302
|
+
run.on('animationend', (name) => console.log(name, 'ended'))
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### `BitmapTextNode`
|
|
306
|
+
|
|
307
|
+
Bitmap-font text.
|
|
308
|
+
|
|
309
|
+
```ts
|
|
310
|
+
import { BitmapTextNode } from 'kiwiengine'
|
|
311
|
+
|
|
312
|
+
const txt = new BitmapTextNode({
|
|
313
|
+
fnt: 'myFont',
|
|
314
|
+
src: 'myFont.fnt',
|
|
315
|
+
text: 'HELLO',
|
|
316
|
+
layer: 'ui',
|
|
317
|
+
})
|
|
318
|
+
txt.changeFont('myFont2', 'myFont2.fnt')
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### `CircleNode` / `RectangleNode`
|
|
322
|
+
|
|
323
|
+
Primitive shapes.
|
|
324
|
+
|
|
325
|
+
```ts
|
|
326
|
+
new CircleNode({ radius: 40, fill: 0xffffff, layer:'game' })
|
|
327
|
+
new RectangleNode({ width: 200, height: 80, stroke: { color: 0x00ff00, width: 2 } })
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### `SpriteNode`
|
|
331
|
+
|
|
332
|
+
Single-texture sprite.
|
|
333
|
+
|
|
334
|
+
```ts
|
|
335
|
+
import { SpriteNode } from 'kiwiengine'
|
|
336
|
+
const logo = new SpriteNode({ src: 'logo.png', layer: 'ui' })
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### `SpineNode`
|
|
340
|
+
|
|
341
|
+
[Spine](http://esotericsoftware.com/) animation support with `animationend` event.
|
|
342
|
+
|
|
343
|
+
```ts
|
|
344
|
+
import { SpineNode } from 'kiwiengine'
|
|
345
|
+
|
|
346
|
+
const spine = new SpineNode({
|
|
347
|
+
atlas: 'spine.atlas',
|
|
348
|
+
texture: { 'page0': 'spine_page0.png' }, // single or multi textures
|
|
349
|
+
json: 'spine.json', // or skel/rawSkeletonData
|
|
350
|
+
skins: ['base', 'hat'],
|
|
351
|
+
animation: 'idle',
|
|
352
|
+
loop: true,
|
|
353
|
+
})
|
|
354
|
+
spine.on('animationend', (a) => console.log(a, 'done'))
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
### `ParticleSystem`
|
|
358
|
+
|
|
359
|
+
Simple particle **burst**.
|
|
360
|
+
|
|
361
|
+
```ts
|
|
362
|
+
import { ParticleSystem } from 'kiwiengine'
|
|
363
|
+
|
|
364
|
+
const ps = new ParticleSystem({
|
|
365
|
+
texture: 'spark.png',
|
|
366
|
+
count: { min: 12, max: 20 },
|
|
367
|
+
lifespan: { min: 0.4, max: 0.8 },
|
|
368
|
+
angle: { min: 0, max: Math.PI * 2 },
|
|
369
|
+
velocity: { min: 200, max: 400 },
|
|
370
|
+
particleScale: { min: 0.5, max: 1.2 },
|
|
371
|
+
startAlpha: 1,
|
|
372
|
+
fadeRate: -1.5,
|
|
373
|
+
orientToVelocity: true,
|
|
374
|
+
})
|
|
375
|
+
|
|
376
|
+
await ps.burst({ x: 0, y: 0 })
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### `DelayNode`
|
|
380
|
+
|
|
381
|
+
Runs a callback after a delay, then removes itself from its parent.
|
|
382
|
+
|
|
383
|
+
```ts
|
|
384
|
+
import { DelayNode } from 'kiwiengine'
|
|
385
|
+
|
|
386
|
+
const delayNode = new DelayNode(2, () => {
|
|
387
|
+
console.log('2 seconds have passed.')
|
|
388
|
+
})
|
|
389
|
+
parent.add(delayNode)
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### `IntervalNode`
|
|
393
|
+
|
|
394
|
+
Game-loop-based `setInterval`-like callback.
|
|
395
|
+
|
|
396
|
+
```ts
|
|
397
|
+
import { IntervalNode } from 'kiwiengine'
|
|
398
|
+
|
|
399
|
+
const repeater = new IntervalNode(1, () => console.log('every 1 second'))
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### `DomContainerNode`
|
|
403
|
+
|
|
404
|
+
Attach a DOM element that follows the **game coordinate system** (position, rotation, scale).
|
|
405
|
+
|
|
406
|
+
```ts
|
|
407
|
+
import { DomContainerNode } from 'kiwiengine'
|
|
408
|
+
|
|
409
|
+
const el = document.createElement('div')
|
|
410
|
+
const dom = new DomContainerNode(el, { x: 0, y: 0, layer: 'ui' })
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
## Physics
|
|
416
|
+
|
|
417
|
+
### `PhysicsWorld({ gravity? })`
|
|
418
|
+
|
|
419
|
+
A world that simulates gravity and collisions for **`PhysicsObject`** children.
|
|
420
|
+
|
|
421
|
+
```ts
|
|
422
|
+
import { PhysicsWorld } from 'kiwiengine'
|
|
423
|
+
|
|
424
|
+
const world = new PhysicsWorld({ gravity: 1000 })
|
|
425
|
+
world.gravity = 800
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
### `PhysicsObject(options)`
|
|
429
|
+
|
|
430
|
+
Creates a physics body from a **collider** and keeps its render transform in sync.
|
|
431
|
+
|
|
432
|
+
```ts
|
|
433
|
+
import { PhysicsObject, RigidbodyType } from 'kiwiengine'
|
|
434
|
+
|
|
435
|
+
const ball = new PhysicsObject({
|
|
436
|
+
rigidbody: { type: RigidbodyType.Circle, radius: 20 },
|
|
437
|
+
x: 0, y: 200, velocityY: -600, useYSort: true,
|
|
438
|
+
})
|
|
439
|
+
|
|
440
|
+
ball.x += 10 // properties stay in sync
|
|
441
|
+
ball.isStatic = false
|
|
442
|
+
ball.disableCollisions() // remove from world (rendering stays)
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
---
|
|
446
|
+
|
|
447
|
+
## DOM Nodes (CSS Rendering)
|
|
448
|
+
|
|
449
|
+
DOM-rendered alternatives for UI/overlays.
|
|
450
|
+
|
|
451
|
+
### `DomSpriteNode`
|
|
452
|
+
|
|
453
|
+
Render an image with the DOM.
|
|
454
|
+
|
|
455
|
+
```ts
|
|
456
|
+
import { DomSpriteNode } from 'kiwiengine'
|
|
457
|
+
new DomSpriteNode({ src: 'ui/button.png', layer: 'ui' })
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
### `DomAnimatedSpriteNode`
|
|
461
|
+
|
|
462
|
+
Spritesheet animation with DOM.
|
|
463
|
+
|
|
464
|
+
```ts
|
|
465
|
+
import { DomAnimatedSpriteNode } from 'kiwiengine'
|
|
466
|
+
|
|
467
|
+
const anim = new DomAnimatedSpriteNode({
|
|
468
|
+
src: 'atlas.png', atlas: atlasJson,
|
|
469
|
+
animation: 'blink', fps: 8, loop: true,
|
|
470
|
+
})
|
|
471
|
+
anim.on('animationend', () => {})
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
### `DomParticleSystem`
|
|
475
|
+
|
|
476
|
+
CSS-driven lightweight particles (API mirrors `ParticleSystem`).
|
|
477
|
+
|
|
478
|
+
```ts
|
|
479
|
+
import { DomParticleSystem } from 'kiwiengine'
|
|
480
|
+
|
|
481
|
+
const dps = new DomParticleSystem({ /* similar to ParticleSystem */ })
|
|
482
|
+
await dps.burst({ x: 300, y: 100 })
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
### `domPreload(assets, progressCallback?)`
|
|
486
|
+
|
|
487
|
+
Preload **DOM** assets (images/fonts).
|
|
488
|
+
|
|
489
|
+
```ts
|
|
490
|
+
import { domPreload } from 'kiwiengine'
|
|
491
|
+
|
|
492
|
+
const releaseDom = await domPreload(['ui/button.png', 'Pretendard'])
|
|
493
|
+
releaseDom()
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
---
|
|
497
|
+
|
|
498
|
+
## Input
|
|
499
|
+
|
|
500
|
+
### `Joystick`
|
|
501
|
+
|
|
502
|
+
Unified **vector input** from mobile touch joystick **and** keyboard arrow keys.
|
|
503
|
+
|
|
504
|
+
```ts
|
|
505
|
+
import { Joystick } from 'kiwiengine'
|
|
506
|
+
|
|
507
|
+
const joy = new Joystick({
|
|
508
|
+
onMove: (angleRad, strength) => {
|
|
509
|
+
// angle in radians, strength in [0..1]
|
|
510
|
+
},
|
|
511
|
+
onRelease: () => {},
|
|
512
|
+
// Optional touch skin
|
|
513
|
+
joystickImage: document.getElementById('joy') as HTMLDivElement,
|
|
514
|
+
knobImage: document.getElementById('knob') as HTMLDivElement,
|
|
515
|
+
maxKnobDistance: 80,
|
|
516
|
+
moveThreshold: 6,
|
|
517
|
+
})
|
|
518
|
+
|
|
519
|
+
// After layout changes, update idle position:
|
|
520
|
+
joy.setIdlePosition({ left: -999999, top: -999999 })
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
---
|
|
524
|
+
|
|
525
|
+
## Utils
|
|
526
|
+
|
|
527
|
+
### `isMobile: boolean`
|
|
528
|
+
|
|
529
|
+
Simple UA-based mobile detection.
|
|
530
|
+
|
|
531
|
+
```ts
|
|
532
|
+
import { isMobile } from 'kiwiengine'
|
|
533
|
+
if (isMobile) {
|
|
534
|
+
// mobile-only logic
|
|
535
|
+
}
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
### `setStyle(el, styles)`
|
|
539
|
+
|
|
540
|
+
DOM style helper.
|
|
541
|
+
|
|
542
|
+
```ts
|
|
543
|
+
import { setStyle } from 'kiwiengine'
|
|
544
|
+
setStyle(div, { opacity: '0.8', pointerEvents: 'none' })
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
### `textStroke(target, width, color)`
|
|
548
|
+
|
|
549
|
+
Apply text outline using multiple `text-shadow`s.
|
|
550
|
+
|
|
551
|
+
```ts
|
|
552
|
+
import { textStroke } from 'kiwiengine'
|
|
553
|
+
textStroke(h1, 2, '#000')
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
---
|
|
557
|
+
|
|
558
|
+
## Debug
|
|
559
|
+
|
|
560
|
+
### `debugMode` / `enableDebug()`
|
|
561
|
+
|
|
562
|
+
Toggle debug features (e.g., **6 FPS fixed-step cap** in unfocused tabs for both `Ticker` and `Renderer`).
|
|
563
|
+
|
|
564
|
+
```ts
|
|
565
|
+
import { enableDebug, debugMode } from 'kiwiengine'
|
|
566
|
+
|
|
567
|
+
enableDebug()
|
|
568
|
+
console.log(debugMode) // true
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
---
|
|
572
|
+
|
|
573
|
+
## License
|
|
6
574
|
|
|
7
|
-
## 라이센스
|
|
8
575
|
MIT
|
|
576
|
+
|
|
577
|
+
## Author
|
|
578
|
+
|
|
579
|
+
Jason
|
|
Binary file
|