diff --git a/assets/dark-ages-buildings.png b/assets/dark-ages-buildings.png new file mode 100644 index 0000000..634becb Binary files /dev/null and b/assets/dark-ages-buildings.png differ diff --git a/assets/dark-ages-buildings.psd b/assets/dark-ages-buildings.psd new file mode 100644 index 0000000..4619d6b Binary files /dev/null and b/assets/dark-ages-buildings.psd differ diff --git a/src/config/buildings.js b/src/config/buildings.js new file mode 100644 index 0000000..15738ee --- /dev/null +++ b/src/config/buildings.js @@ -0,0 +1,16 @@ +export const BUILDING_CONFIG = { + 'dark-ages': { + barracks1: { + frame: 2 + }, + barracks2: { + frame: 2 + }, + hq: { + frame: 3 + }, + midBase: { + frame: 11 + } + } +} \ No newline at end of file diff --git a/src/config/night-woods-config.js b/src/config/night-woods-config.js index eb44db8..0c953a7 100644 --- a/src/config/night-woods-config.js +++ b/src/config/night-woods-config.js @@ -1,5 +1,23 @@ export const PATH_CONFIG = { 'left': { + buildings: { + barracks1: { + x: 2, + y: 4, + }, + hq: { + x: 3, + y: 8.5, + }, + barracks2: { + x: 2, + y: 13, + }, + midBase: { + x: 16, + y: 8.5 + } + }, 1: { 0: { 'x': 4, diff --git a/src/faction/buildings.js b/src/faction/buildings.js new file mode 100644 index 0000000..b929e57 --- /dev/null +++ b/src/faction/buildings.js @@ -0,0 +1,21 @@ +import { PATH_CONFIG } from "../config/night-woods-config.js"; +import { BUILDING_CONFIG } from "../config/buildings.js"; + +export class Buildings { + constructor(scene, faction, side) { + this.scene = scene; + this.faction = faction; + this.side = side; + this.buildings = {}; + + this.create(); + } + + create() { + Object.entries(PATH_CONFIG[this.side].buildings).forEach(([key, value]) => { + console.log('x',value.x,'y',value.y,'key',BUILDING_CONFIG[this.faction][key]); + this.scene.add.sprite(value.x * 64, value.y * 64, `${this.faction}-buildings`, BUILDING_CONFIG[this.faction][key].frame) + .setOrigin(0.5); + }); + } +} \ No newline at end of file diff --git a/src/faction/factions.js b/src/faction/factions.js index 4dd7062..f25a263 100644 --- a/src/faction/factions.js +++ b/src/faction/factions.js @@ -215,6 +215,7 @@ export class Faction extends Phaser.GameObjects.Sprite { const status = this.enemy.takeDamage('melee', Phaser.Math.Between(this.stats.attackMin, this.stats.attackMax)); if (status === 'dead') { this.enemy = false; + this.play(this.animKey); this.resumePath(); } } diff --git a/src/scenes/level.js b/src/scenes/level.js index a3711c2..77d20cc 100644 --- a/src/scenes/level.js +++ b/src/scenes/level.js @@ -1,3 +1,4 @@ +import { Buildings } from '../faction/buildings.js'; import { Faction } from '../faction/factions.js'; export class Level extends Phaser.Scene { @@ -26,6 +27,10 @@ export class Level extends Phaser.Scene { frameWidth: 64, frameHeight: 64 }); + this.load.spritesheet('dark-ages-buildings', '/assets/dark-ages-buildings.png', { + frameWidth: 192, + frameHeight: 192 + }); } create() { @@ -41,6 +46,11 @@ export class Level extends Phaser.Scene { this.factionLeft = this.add.group(); this.factionRight = this.add.group(); + + this.leftBuildings = new Buildings(this, 'dark-ages', 'left'); + + // Set camera bounds to map dimensions + this.cameras.main.setBounds(0, 0, this.mainLayer.width, this.mainLayer.height); } update(time, delta) {