kiwiengine 0.5.2 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +2 -2
- package/README.md +2 -2
- 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/dom-sprite-test/index.ts +6 -9
- package/examples/simple-battle/assets/spritesheets/hero-atlas.json +180 -223
- package/examples/simple-battle/assets/spritesheets/orc-atlas.json +180 -223
- package/examples/simple-battle/assets/spritesheets/potion-atlas.json +46 -61
- package/examples/simple-battle/hud/damage-text.ts +1 -0
- package/examples/simple-battle/hud/heal-text.ts +1 -0
- package/examples/simple-battle/objects/character.ts +3 -3
- package/examples/simple-battle/objects/hero.ts +3 -5
- package/examples/simple-battle/objects/orc.ts +3 -5
- package/examples/simple-battle/objects/potion.ts +0 -2
- package/examples/simple-battle/stage.ts +2 -4
- package/examples/sprite-test/index.ts +6 -9
- package/examples/webpack.config.js +4 -1
- package/lib/asset/loaders/audio.js +4 -1
- package/lib/asset/loaders/audio.js.map +1 -1
- package/lib/asset/loaders/binary.js +4 -1
- package/lib/asset/loaders/binary.js.map +1 -1
- package/lib/asset/loaders/bitmap-font.js +24 -21
- package/lib/asset/loaders/bitmap-font.js.map +1 -1
- package/lib/asset/loaders/font.js +3 -0
- package/lib/asset/loaders/font.js.map +1 -1
- package/lib/asset/loaders/spritesheet.js +12 -1
- package/lib/asset/loaders/spritesheet.js.map +1 -1
- package/lib/asset/loaders/text.js +3 -0
- package/lib/asset/loaders/text.js.map +1 -1
- package/lib/asset/loaders/texture.js +21 -26
- package/lib/asset/loaders/texture.js.map +1 -1
- package/lib/asset/preload.js.map +1 -1
- package/lib/collision/check-collision.js +16 -16
- package/lib/collision/check-collision.js.map +1 -1
- package/lib/dom/dom-animated-sprite.js +21 -36
- package/lib/dom/dom-animated-sprite.js.map +1 -1
- package/lib/dom/dom-game-object.js +9 -7
- package/lib/dom/dom-game-object.js.map +1 -1
- package/lib/dom/dom-particle.js.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/node/core/dirty-number.js +0 -19
- package/lib/node/core/dirty-number.js.map +1 -1
- package/lib/node/core/renderable.js +7 -0
- package/lib/node/core/renderable.js.map +1 -1
- package/lib/node/core/transform.js +22 -11
- package/lib/node/core/transform.js.map +1 -1
- package/lib/node/ext/animated-sprite.js +3 -22
- package/lib/node/ext/animated-sprite.js.map +1 -1
- package/lib/node/ext/bitmap-text.js +7 -3
- package/lib/node/ext/bitmap-text.js.map +1 -1
- package/lib/node/ext/circle.js +18 -3
- package/lib/node/ext/circle.js.map +1 -1
- package/lib/node/ext/deplay.js +2 -0
- package/lib/node/ext/deplay.js.map +1 -1
- package/lib/node/ext/dom-container.js +2 -2
- package/lib/node/ext/dom-container.js.map +1 -1
- package/lib/node/ext/interval.js +2 -0
- package/lib/node/ext/interval.js.map +1 -1
- package/lib/node/ext/particle.js.map +1 -1
- package/lib/node/ext/rectangle.js +24 -4
- package/lib/node/ext/rectangle.js.map +1 -1
- package/lib/node/physics/physics-object.js +9 -29
- package/lib/node/physics/physics-object.js.map +1 -1
- package/lib/node/physics/physics-world.js +2 -0
- package/lib/node/physics/physics-world.js.map +1 -1
- package/lib/node/physics/rigidbodies.js +7 -0
- package/lib/node/physics/rigidbodies.js.map +1 -0
- package/lib/renderer/renderer.js +3 -2
- package/lib/renderer/renderer.js.map +1 -1
- package/lib/types/animation-atlas.js +2 -0
- package/lib/types/animation-atlas.js.map +1 -0
- package/lib/types/asset/loaders/audio.d.ts +1 -0
- package/lib/types/asset/loaders/audio.d.ts.map +1 -1
- package/lib/types/asset/loaders/binary.d.ts +1 -0
- package/lib/types/asset/loaders/binary.d.ts.map +1 -1
- package/lib/types/asset/loaders/bitmap-font.d.ts +1 -0
- package/lib/types/asset/loaders/bitmap-font.d.ts.map +1 -1
- package/lib/types/asset/loaders/font.d.ts +1 -0
- package/lib/types/asset/loaders/font.d.ts.map +1 -1
- package/lib/types/asset/loaders/spritesheet.d.ts +11 -3
- package/lib/types/asset/loaders/spritesheet.d.ts.map +1 -1
- package/lib/types/asset/loaders/text.d.ts +1 -0
- package/lib/types/asset/loaders/text.d.ts.map +1 -1
- package/lib/types/asset/loaders/texture.d.ts +1 -1
- package/lib/types/asset/loaders/texture.d.ts.map +1 -1
- package/lib/types/asset/preload.d.ts +2 -2
- 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/dom/dom-animated-sprite.d.ts +4 -10
- package/lib/types/dom/dom-animated-sprite.d.ts.map +1 -1
- package/lib/types/dom/dom-game-object.d.ts +1 -1
- package/lib/types/dom/dom-game-object.d.ts.map +1 -1
- package/lib/types/dom/dom-particle.d.ts.map +1 -1
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/node/core/dirty-number.d.ts +0 -8
- package/lib/types/node/core/dirty-number.d.ts.map +1 -1
- package/lib/types/node/core/renderable.d.ts +1 -0
- package/lib/types/node/core/renderable.d.ts.map +1 -1
- package/lib/types/node/core/transform.d.ts +4 -2
- package/lib/types/node/core/transform.d.ts.map +1 -1
- package/lib/types/node/ext/animated-sprite.d.ts +4 -10
- package/lib/types/node/ext/animated-sprite.d.ts.map +1 -1
- package/lib/types/node/ext/bitmap-text.d.ts.map +1 -1
- package/lib/types/node/ext/circle.d.ts +3 -3
- package/lib/types/node/ext/circle.d.ts.map +1 -1
- package/lib/types/node/ext/deplay.d.ts.map +1 -1
- package/lib/types/node/ext/dom-container.d.ts +1 -1
- package/lib/types/node/ext/dom-container.d.ts.map +1 -1
- package/lib/types/node/ext/interval.d.ts.map +1 -1
- package/lib/types/node/ext/particle.d.ts.map +1 -1
- package/lib/types/node/ext/rectangle.d.ts +4 -4
- package/lib/types/node/ext/rectangle.d.ts.map +1 -1
- package/lib/types/node/physics/physics-object.d.ts +2 -2
- package/lib/types/node/physics/physics-object.d.ts.map +1 -1
- package/lib/types/node/physics/physics-world.d.ts.map +1 -1
- 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/renderer.d.ts.map +1 -1
- 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/sprite-atlas.d.ts +13 -0
- package/lib/types/types/sprite-atlas.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/asset/loaders/audio.ts +5 -2
- package/src/asset/loaders/binary.ts +5 -1
- package/src/asset/loaders/bitmap-font.ts +33 -27
- package/src/asset/loaders/font.ts +4 -0
- package/src/asset/loaders/spritesheet.ts +18 -5
- package/src/asset/loaders/text.ts +4 -0
- package/src/asset/loaders/texture.ts +19 -27
- package/src/asset/preload.ts +4 -8
- package/src/collision/check-collision.ts +16 -16
- package/src/dom/dom-animated-sprite.ts +24 -45
- package/src/dom/dom-game-object.ts +9 -6
- package/src/dom/dom-particle.ts +1 -1
- package/src/index.ts +2 -0
- package/src/node/core/dirty-number.ts +0 -24
- package/src/node/core/renderable.ts +7 -0
- package/src/node/core/transform.ts +23 -11
- package/src/node/ext/animated-sprite.ts +9 -29
- package/src/node/ext/bitmap-text.ts +7 -3
- package/src/node/ext/circle.ts +18 -3
- package/src/node/ext/deplay.ts +1 -0
- package/src/node/ext/dom-container.ts +2 -2
- package/src/node/ext/interval.ts +1 -0
- package/src/node/ext/particle.ts +1 -1
- package/src/node/ext/rectangle.ts +24 -4
- package/src/node/physics/physics-object.ts +11 -40
- package/src/node/physics/physics-world.ts +1 -0
- package/src/node/physics/rigidbodies.ts +14 -0
- package/src/renderer/renderer.ts +4 -3
- package/src/types/atlas.ts +17 -0
- package/examples/flappy-cat/assets/bgm/bgm.ogg +0 -0
- package/examples/flappy-cat/assets/images/base.png +0 -0
- package/examples/flappy-cat/assets/images/bg.png +0 -0
- package/examples/flappy-cat/assets/images/cat.png +0 -0
- package/examples/flappy-cat/assets/images/pipe-green.png +0 -0
- package/examples/flappy-cat/assets/images/pipe-red.png +0 -0
- package/examples/flappy-cat/assets/sfx/die.wav +0 -0
- package/examples/flappy-cat/assets/sfx/hit.wav +0 -0
- package/examples/flappy-cat/assets/sfx/point.wav +0 -0
- package/examples/flappy-cat/assets/sfx/wing.wav +0 -0
- package/examples/flappy-cat/dist/game.js +0 -0
- package/examples/flappy-cat/index.ts +0 -0
- /package/examples/{flappy-cat → auto-battle}/index.html +0 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AnimatedSpriteNode,
|
|
3
|
+
ColliderType,
|
|
4
|
+
DelayNode,
|
|
5
|
+
GameObjectOptions,
|
|
6
|
+
RigidbodyType,
|
|
7
|
+
sfxPlayer,
|
|
8
|
+
} from '../../../src/index'
|
|
9
|
+
import orcAtlas from '../assets/spritesheets/orc-atlas.json'
|
|
10
|
+
import { Character } from './character'
|
|
11
|
+
|
|
12
|
+
const ORC_MOVE_SPEED = 3 as const // 엔진이 dt(초)를 주면 아래 step 계산 주석 참고
|
|
13
|
+
const ORC_HITBOX_X = 24 as const
|
|
14
|
+
const ORC_ATTACK_DAMAGE = 1 as const
|
|
15
|
+
const EPS = 1e-3 // 스냅/오버슈트 방지용
|
|
16
|
+
const EPS2 = EPS * EPS
|
|
17
|
+
|
|
18
|
+
export class Orc extends Character<{
|
|
19
|
+
hit: (damage: number) => void
|
|
20
|
+
dead: () => void
|
|
21
|
+
}> {
|
|
22
|
+
protected _sprite: AnimatedSpriteNode
|
|
23
|
+
|
|
24
|
+
// ── 타겟/방향(정규화) ─────────────────────────────────────────────
|
|
25
|
+
#tx: number | null = null
|
|
26
|
+
#ty: number | null = null
|
|
27
|
+
#dirX = 0
|
|
28
|
+
#dirY = 0
|
|
29
|
+
#moveSpeed = ORC_MOVE_SPEED
|
|
30
|
+
|
|
31
|
+
// ── 상태 ─────────────────────────────────────────────────────────
|
|
32
|
+
#attacking = false
|
|
33
|
+
|
|
34
|
+
constructor(options?: GameObjectOptions) {
|
|
35
|
+
super({
|
|
36
|
+
...options,
|
|
37
|
+
maxHp: 100,
|
|
38
|
+
hp: 100,
|
|
39
|
+
rigidbody: { type: RigidbodyType.Rectangle, width: 30, height: 30 },
|
|
40
|
+
hitbox: { type: ColliderType.Rectangle, width: 32, height: 52, x: ORC_HITBOX_X, y: -8 },
|
|
41
|
+
hurtbox: { type: ColliderType.Rectangle, width: 24, height: 32, x: 0, y: 0 },
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
this._sprite = new AnimatedSpriteNode({
|
|
45
|
+
src: 'assets/spritesheets/orc.png',
|
|
46
|
+
atlas: orcAtlas,
|
|
47
|
+
animation: 'idle',
|
|
48
|
+
scale: 2,
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
this._sprite.on('animationend', (animation: string) => {
|
|
52
|
+
if (animation.startsWith('attack')) {
|
|
53
|
+
this.#attacking = false
|
|
54
|
+
// 이동 중이면 walk, 아니면 idle (중복 전환 방지)
|
|
55
|
+
if (this.#isMoving()) this.#setWalk()
|
|
56
|
+
else this.#setIdle()
|
|
57
|
+
} else if (animation === 'die') {
|
|
58
|
+
this.emit('dead')
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
this.add(this._sprite)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ── 외부 인터페이스 ──────────────────────────────────────────────
|
|
66
|
+
moveTo(x: number, y: number) {
|
|
67
|
+
if (this.dead) return
|
|
68
|
+
this.#tx = x
|
|
69
|
+
this.#ty = y
|
|
70
|
+
|
|
71
|
+
// 방향 벡터 미리 정규화(삼각함수 없음)
|
|
72
|
+
const dx = x - this.x
|
|
73
|
+
const dy = y - this.y
|
|
74
|
+
const len2 = dx * dx + dy * dy
|
|
75
|
+
if (len2 > EPS2) {
|
|
76
|
+
// 역길이 계산(정확 sqrt 대신 1/sqrt 사용; JS에 fast invsqrt 없음)
|
|
77
|
+
const invLen = 1 / Math.sqrt(len2)
|
|
78
|
+
this.#dirX = dx * invLen
|
|
79
|
+
this.#dirY = dy * invLen
|
|
80
|
+
} else {
|
|
81
|
+
this.#dirX = 0
|
|
82
|
+
this.#dirY = 0
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// 좌우 플립/히트박스 오프셋(부호만 필요)
|
|
86
|
+
const scale = Math.abs(this._sprite.scaleX)
|
|
87
|
+
this._sprite.scaleX = dx >= 0 ? scale : -scale
|
|
88
|
+
this.hitboxX = dx >= 0 ? ORC_HITBOX_X : -ORC_HITBOX_X
|
|
89
|
+
|
|
90
|
+
if (!this.#attacking) this.#setWalk()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
stop() {
|
|
94
|
+
this.#tx = null
|
|
95
|
+
this.#ty = null
|
|
96
|
+
this.#dirX = 0
|
|
97
|
+
this.#dirY = 0
|
|
98
|
+
if (!this.#attacking && !this.dead) this.#setIdle()
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
attack() {
|
|
102
|
+
if (this.dead || this.#attacking) return
|
|
103
|
+
this.#attacking = true
|
|
104
|
+
// 이동 즉시 정지(불필요한 계산 차단)
|
|
105
|
+
this.#tx = null
|
|
106
|
+
this.#ty = null
|
|
107
|
+
this.#dirX = 0
|
|
108
|
+
this.#dirY = 0
|
|
109
|
+
|
|
110
|
+
// 랜덤 공격 모션(애니메이션 변경 최소)
|
|
111
|
+
const nextAnim = (Math.random() < 0.5) ? 'attack1' : 'attack2'
|
|
112
|
+
if (this._sprite.animation !== nextAnim) {
|
|
113
|
+
this._sprite.animation = nextAnim
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// 타격 타이밍
|
|
117
|
+
this.add(new DelayNode(0.3, () => this.emit('hit', ORC_ATTACK_DAMAGE)))
|
|
118
|
+
|
|
119
|
+
// SFX (대량 동시 재생은 믹서에서 한정/풀링 권장)
|
|
120
|
+
sfxPlayer.playRandom(
|
|
121
|
+
'assets/sfx/orc/miss/miss1.wav',
|
|
122
|
+
'assets/sfx/orc/miss/miss2.wav',
|
|
123
|
+
'assets/sfx/orc/miss/miss3.wav'
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// ── 루프 ─────────────────────────────────────────────────────────
|
|
128
|
+
protected override update(dt: number) {
|
|
129
|
+
if (this.paused) return
|
|
130
|
+
super.update(dt)
|
|
131
|
+
|
|
132
|
+
if (this.dead || this.#attacking) return
|
|
133
|
+
if (this.#tx === null || this.#ty === null) return
|
|
134
|
+
|
|
135
|
+
// 남은 거리 제곱(정확 sqrt 불필요)
|
|
136
|
+
const rx = this.#tx - this.x
|
|
137
|
+
const ry = this.#ty - this.y
|
|
138
|
+
const remaining2 = rx * rx + ry * ry
|
|
139
|
+
if (remaining2 <= EPS2) {
|
|
140
|
+
// 도착 처리
|
|
141
|
+
this.x = this.#tx
|
|
142
|
+
this.y = this.#ty
|
|
143
|
+
this.stop()
|
|
144
|
+
return
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// 한 프레임 이동량(step)
|
|
148
|
+
const step = this.#moveSpeed * (dt > 0 ? dt * 60 : 1) // 프레임 기준 정규화
|
|
149
|
+
|
|
150
|
+
// 오버슈트 방지: step^2와 remaining^2 비교
|
|
151
|
+
const step2 = step * step
|
|
152
|
+
if (remaining2 <= step2) {
|
|
153
|
+
this.x = this.#tx
|
|
154
|
+
this.y = this.#ty
|
|
155
|
+
this.stop()
|
|
156
|
+
return
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// 미리 정규화해둔 방향으로 이동(삼각함수 없음)
|
|
160
|
+
this.x += this.#dirX * step
|
|
161
|
+
this.y += this.#dirY * step
|
|
162
|
+
|
|
163
|
+
// 진행 방향에 따른 좌우 플립/히트박스 (dirX 부호만 사용)
|
|
164
|
+
const scale = Math.abs(this._sprite.scaleX)
|
|
165
|
+
const dirX = this.#dirX
|
|
166
|
+
if (dirX > 0) {
|
|
167
|
+
if (this._sprite.scaleX < 0) this._sprite.scaleX = scale
|
|
168
|
+
if (this.hitboxX !== ORC_HITBOX_X) this.hitboxX = ORC_HITBOX_X
|
|
169
|
+
} else if (dirX < 0) {
|
|
170
|
+
if (this._sprite.scaleX > 0) this._sprite.scaleX = -scale
|
|
171
|
+
if (this.hitboxX !== -ORC_HITBOX_X) this.hitboxX = -ORC_HITBOX_X
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// 이동 중 애니메이션 보장(중복 전환 방지)
|
|
175
|
+
if (this._sprite.animation !== 'walk') this.#setWalk()
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// ── 피격/사망 ────────────────────────────────────────────────────
|
|
179
|
+
override takeDamage(damage: number) {
|
|
180
|
+
super.takeDamage(damage)
|
|
181
|
+
sfxPlayer.playRandom(
|
|
182
|
+
'assets/sfx/orc/hit/hit1.wav',
|
|
183
|
+
'assets/sfx/orc/hit/hit2.wav',
|
|
184
|
+
'assets/sfx/orc/hit/hit3.wav'
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
protected override onDie() {
|
|
189
|
+
this.#tx = null
|
|
190
|
+
this.#ty = null
|
|
191
|
+
this.#dirX = 0
|
|
192
|
+
this.#dirY = 0
|
|
193
|
+
if (this._sprite.animation !== 'die') {
|
|
194
|
+
this._sprite.animation = 'die'
|
|
195
|
+
}
|
|
196
|
+
sfxPlayer.play('assets/sfx/orc/die/die.wav')
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// ── 내부 유틸 ────────────────────────────────────────────────────
|
|
200
|
+
#isMoving() {
|
|
201
|
+
return this.#tx !== null && this.#ty !== null
|
|
202
|
+
}
|
|
203
|
+
#setWalk() {
|
|
204
|
+
if (this._sprite.animation !== 'walk') {
|
|
205
|
+
this._sprite.animation = 'walk'
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
#setIdle() {
|
|
209
|
+
if (this._sprite.animation !== 'idle') {
|
|
210
|
+
this._sprite.animation = 'idle'
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AnimatedSpriteNode, CircleCollider, CircleNode, ColliderType, debugMode, GameObject, GameObjectOptions } from '../../../src'
|
|
2
|
+
import potionAtlas from '../assets/spritesheets/potion-atlas.json'
|
|
3
|
+
|
|
4
|
+
export type PotionOptions = {
|
|
5
|
+
healAmount?: number
|
|
6
|
+
} & GameObjectOptions
|
|
7
|
+
|
|
8
|
+
export class Potion extends GameObject {
|
|
9
|
+
triggerCollider: CircleCollider = { type: ColliderType.Circle, radius: 16 }
|
|
10
|
+
healAmount: number
|
|
11
|
+
|
|
12
|
+
constructor(options?: PotionOptions) {
|
|
13
|
+
super({ ...options, useYSort: true })
|
|
14
|
+
this.healAmount = options?.healAmount ?? 100
|
|
15
|
+
|
|
16
|
+
this.add(new AnimatedSpriteNode({
|
|
17
|
+
src: 'assets/spritesheets/potion.png',
|
|
18
|
+
atlas: potionAtlas,
|
|
19
|
+
animation: 'animation',
|
|
20
|
+
scale: 2
|
|
21
|
+
}))
|
|
22
|
+
|
|
23
|
+
if (debugMode) {
|
|
24
|
+
this.add(new CircleNode({ ...this.triggerCollider, stroke: 'green', alpha: 0.5, layer: 'hud' }))
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { checkCollision, GameObject, IntervalNode, isMobile, Joystick, musicPlayer } from '../../src'
|
|
2
|
+
import { Hero } from './objects/hero'
|
|
3
|
+
import { Orc } from './objects/orc'
|
|
4
|
+
import { Potion } from './objects/potion'
|
|
5
|
+
|
|
6
|
+
function createTextElement() {
|
|
7
|
+
const el = document.createElement('div')
|
|
8
|
+
el.style.color = 'white'
|
|
9
|
+
el.style.position = 'absolute'
|
|
10
|
+
el.style.top = '10px'
|
|
11
|
+
el.style.zIndex = '1'
|
|
12
|
+
return el
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const SCORE_PER_ORC = 100
|
|
16
|
+
|
|
17
|
+
export class Stage extends GameObject {
|
|
18
|
+
#hero = new Hero();
|
|
19
|
+
#orcs: Set<Orc> = new Set();
|
|
20
|
+
#potions: Set<Potion> = new Set();
|
|
21
|
+
|
|
22
|
+
#time = 0
|
|
23
|
+
#score = 0
|
|
24
|
+
#isGameOver = false
|
|
25
|
+
|
|
26
|
+
#timeText: HTMLDivElement
|
|
27
|
+
#hpText: HTMLDivElement
|
|
28
|
+
#scoreText: HTMLDivElement
|
|
29
|
+
|
|
30
|
+
#spawnOrcInterval: IntervalNode
|
|
31
|
+
#spawnPotionInterval: IntervalNode
|
|
32
|
+
|
|
33
|
+
constructor() {
|
|
34
|
+
super()
|
|
35
|
+
musicPlayer.play('assets/bgm/battle.mp3')
|
|
36
|
+
|
|
37
|
+
this.add(this.#hero)
|
|
38
|
+
this.add(this.#spawnOrcInterval = new IntervalNode(1, () => this.#spawnOrc()))
|
|
39
|
+
this.add(this.#spawnPotionInterval = new IntervalNode(3, () => this.#spawnPotion()))
|
|
40
|
+
|
|
41
|
+
for (let i = 0; i < 1000; i++) {
|
|
42
|
+
this.#spawnOrc()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const joystickImage = new Image()
|
|
46
|
+
joystickImage.src = 'assets/joystick/joystick.png'
|
|
47
|
+
|
|
48
|
+
const knobImage = new Image()
|
|
49
|
+
knobImage.src = 'assets/joystick/knob.png'
|
|
50
|
+
|
|
51
|
+
this.add(
|
|
52
|
+
new Joystick({
|
|
53
|
+
onMove: (r, d) => this.#hero.move(r, d),
|
|
54
|
+
onRelease: () => this.#hero.stop(),
|
|
55
|
+
onKeyDown: (code) => {
|
|
56
|
+
if (code === 'KeyA') this.#hero.attack()
|
|
57
|
+
},
|
|
58
|
+
joystickImage,
|
|
59
|
+
knobImage,
|
|
60
|
+
maxKnobDistance: 70,
|
|
61
|
+
}),
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
this.#timeText = createTextElement()
|
|
65
|
+
this.#hpText = createTextElement()
|
|
66
|
+
this.#scoreText = createTextElement()
|
|
67
|
+
|
|
68
|
+
this.#timeText.textContent = `Time: ${this.#time}`
|
|
69
|
+
this.#hpText.textContent = `HP: ${this.#hero.hp}`
|
|
70
|
+
this.#scoreText.textContent = `Score: ${this.#score}`
|
|
71
|
+
|
|
72
|
+
this.#timeText.style.left = '10px'
|
|
73
|
+
this.#hpText.style.left = '50%'
|
|
74
|
+
this.#hpText.style.transform = 'translate(-50%, 0)'
|
|
75
|
+
this.#scoreText.style.right = '10px'
|
|
76
|
+
|
|
77
|
+
this.#hero.on('hit', (damage) => {
|
|
78
|
+
for (const o of this.#orcs) {
|
|
79
|
+
if (checkCollision(this.#hero.hitbox, this.#hero.worldTransform, o.hurtbox, o.worldTransform)) {
|
|
80
|
+
o.takeDamage(damage)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
this.#hero.on('changeHp', () => {
|
|
86
|
+
this.#hpText.textContent = `HP: ${this.#hero.hp}`
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
this.#hero.on('dead', () => {
|
|
90
|
+
this.#gameOver()
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
#gameOver() {
|
|
95
|
+
this.#isGameOver = true
|
|
96
|
+
this.#spawnOrcInterval.remove()
|
|
97
|
+
this.#spawnPotionInterval.remove()
|
|
98
|
+
for (const o of this.#orcs) {
|
|
99
|
+
o.stop()
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const gameOverText = createTextElement()
|
|
103
|
+
gameOverText.textContent = 'Game Over'
|
|
104
|
+
gameOverText.style.left = '50%'
|
|
105
|
+
gameOverText.style.top = '50%'
|
|
106
|
+
gameOverText.style.transform = 'translate(-50%, -50%)'
|
|
107
|
+
this.renderer?.container.append(gameOverText)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
protected override set renderer(renderer) {
|
|
111
|
+
super.renderer = renderer
|
|
112
|
+
|
|
113
|
+
if (renderer) {
|
|
114
|
+
const c = renderer.container
|
|
115
|
+
c.append(this.#timeText, this.#hpText, this.#scoreText)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
protected override get renderer() {
|
|
120
|
+
return super.renderer
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
#spawnOrc() {
|
|
124
|
+
const o = new Orc()
|
|
125
|
+
o.x = Math.random() * 800 - 400
|
|
126
|
+
o.y = Math.random() * 600 - 300
|
|
127
|
+
o.on('hit', (damage) => {
|
|
128
|
+
if (checkCollision(this.#hero.hurtbox, this.#hero.worldTransform, o.hitbox, o.worldTransform)) {
|
|
129
|
+
this.#hero.takeDamage(damage)
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
this.add(o)
|
|
133
|
+
this.#orcs.add(o)
|
|
134
|
+
o.on('dead', () => {
|
|
135
|
+
this.#orcs.delete(o)
|
|
136
|
+
this.#score += SCORE_PER_ORC
|
|
137
|
+
this.#scoreText.textContent = `Score: ${this.#score}`
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
#spawnPotion() {
|
|
142
|
+
const p = new Potion()
|
|
143
|
+
p.x = Math.random() * 800 - 400
|
|
144
|
+
p.y = Math.random() * 600 - 300
|
|
145
|
+
this.add(p)
|
|
146
|
+
this.#potions.add(p)
|
|
147
|
+
p.on('remove', () => this.#potions.delete(p))
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
protected override update(dt: number) {
|
|
151
|
+
if (this.paused) return
|
|
152
|
+
super.update(dt)
|
|
153
|
+
|
|
154
|
+
if (this.#isGameOver) return
|
|
155
|
+
|
|
156
|
+
const h = this.#hero
|
|
157
|
+
if (h.dead) return
|
|
158
|
+
|
|
159
|
+
for (const o of this.#orcs) {
|
|
160
|
+
if (checkCollision(h.hurtbox, h.worldTransform, o.hitbox, o.worldTransform)) {
|
|
161
|
+
o.attack()
|
|
162
|
+
} else {
|
|
163
|
+
o.moveTo(this.#hero.x, this.#hero.y)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (isMobile && checkCollision(h.hitbox, h.worldTransform, o.hurtbox, o.worldTransform)) {
|
|
167
|
+
h.attack()
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
for (const p of this.#potions) {
|
|
172
|
+
if (checkCollision(h.hitbox, h.worldTransform, p.triggerCollider, p.worldTransform)) {
|
|
173
|
+
h.heal(p.healAmount)
|
|
174
|
+
p.remove()
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
@@ -19,20 +19,17 @@ const animatedSprite = new DomAnimatedSpriteNode({
|
|
|
19
19
|
src: 'assets/fire.png',
|
|
20
20
|
atlas: {
|
|
21
21
|
frames: {
|
|
22
|
-
fire1: {
|
|
23
|
-
fire2: {
|
|
24
|
-
fire3: {
|
|
25
|
-
fire4: {
|
|
26
|
-
fire5: {
|
|
22
|
+
fire1: { x: 0, y: 0, w: 64, h: 64 },
|
|
23
|
+
fire2: { x: 64, y: 0, w: 64, h: 64 },
|
|
24
|
+
fire3: { x: 128, y: 0, w: 64, h: 64 },
|
|
25
|
+
fire4: { x: 192, y: 0, w: 64, h: 64 },
|
|
26
|
+
fire5: { x: 256, y: 0, w: 64, h: 64 },
|
|
27
27
|
},
|
|
28
|
-
meta: { scale: 1 },
|
|
29
28
|
animations: {
|
|
30
|
-
fire: ['fire1', 'fire2', 'fire3', 'fire4', 'fire5'],
|
|
29
|
+
fire: { frames: ['fire1', 'fire2', 'fire3', 'fire4', 'fire5'], fps: 12, loop: true },
|
|
31
30
|
},
|
|
32
31
|
},
|
|
33
32
|
animation: 'fire',
|
|
34
|
-
fps: 12,
|
|
35
|
-
loop: true,
|
|
36
33
|
}).attachTo(document.body)
|
|
37
34
|
|
|
38
35
|
new Ticker(dt => animatedSprite.render(dt))
|