From faae7661156588f0cc98276d320475742be0f27f Mon Sep 17 00:00:00 2001 From: Dimitri TRAVAILLOUX Date: Sun, 4 Oct 2020 23:00:55 +0200 Subject: [PATCH 1/3] Fix: enemy sprite color is white when tag patrolling is set instead of #dd00cd color --- chapter-9/example-4-quest/tags/patrolling.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter-9/example-4-quest/tags/patrolling.js b/chapter-9/example-4-quest/tags/patrolling.js index f41f454..1f93015 100644 --- a/chapter-9/example-4-quest/tags/patrolling.js +++ b/chapter-9/example-4-quest/tags/patrolling.js @@ -7,7 +7,7 @@ const patrolling = { this.tint = 0xdd00cd if (this.sprite) { - this.sprite.tint = this.tin + this.sprite.tint = this.tint this.sprite.tintFill = true } From 953ea712b6fa1c3884562535855eaacaf91a949c Mon Sep 17 00:00:00 2001 From: Dimitri TRAVAILLOUX Date: Sun, 4 Oct 2020 23:35:29 +0200 Subject: [PATCH 2/3] Fix: Check inventory lenght before to pick up item (crash game). --- .../example-4-quest/classes/basicHero.js | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/chapter-9/example-4-quest/classes/basicHero.js b/chapter-9/example-4-quest/classes/basicHero.js index beaf116..6b1c473 100644 --- a/chapter-9/example-4-quest/classes/basicHero.js +++ b/chapter-9/example-4-quest/classes/basicHero.js @@ -3,7 +3,7 @@ import Taggable from "../taggable.js" export default class BasicHero extends Taggable { constructor(x, y) { - super(x,y) + super(x, y) this.name = "The Hero" this.movementPoints = 1 this.actionPoints = 1 @@ -17,7 +17,7 @@ export default class BasicHero extends Taggable { } setEvents() { - dungeon.scene.input.keyboard.addCapture(["SPACE", "UP","DOWN","LEFT","RIGHT"]) + dungeon.scene.input.keyboard.addCapture(["SPACE", "UP", "DOWN", "LEFT", "RIGHT"]) dungeon.scene.input.keyboard.on("keyup", (event) => { if (!this.over()) { this.processInput(event) @@ -147,7 +147,7 @@ export default class BasicHero extends Taggable { this.toggleItem(key - 1) } - + // go down the dungeon if (event.key == "d") { dungeon.goDown() @@ -206,17 +206,20 @@ export default class BasicHero extends Taggable { // Check if entity at destination is an item if (entity && entity.type == "item" && this.actionPoints > 0) { - this.items.push(entity) - dungeon.itemPicked(entity) - dungeon.log(`${this.name} picked ${entity.name}: ${entity.description}`) - this.actionPoints -= 1 + // Check if inventory is full + if (this.items.length < 10) { + this.items.push(entity) + dungeon.itemPicked(entity) + dungeon.log(`${this.name} picked ${entity.name}: ${entity.description}`) + this.actionPoints -= 1 + } } else { newX = oldX newY = oldY } // Check if entity at destination is a stair - if (entity && entity.type == "stairs" ) { + if (entity && entity.type == "stairs") { if (entity.direction == "down") { dungeon.goDown() } else { @@ -335,7 +338,7 @@ export default class BasicHero extends Taggable { if (this.UIstatsText) { this.UIstatsText.setText(`Hp: ${this.healthPoints}\nMp: ${this.movementPoints}\nAp: ${this.actionPoints}`) } - + } cleanup() { From 36cd0d6bf6db65ea0fa783fe647059ec698dc5e0 Mon Sep 17 00:00:00 2001 From: Dimitri TRAVAILLOUX Date: Wed, 21 Oct 2020 15:44:34 +0200 Subject: [PATCH 3/3] Initial commit --- chapter-8/example-1-areas/world.js | 2 +- chapter-8/example-2-rooms/bspdungeon.js | 12 +++++------ chapter-8/example-3-corridors/bspdungeon.js | 6 +++++- .../example-4-quest/classes/basicHero.js | 21 ++++++++----------- chapter-9/example-4-quest/tags/patrolling.js | 2 +- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/chapter-8/example-1-areas/world.js b/chapter-8/example-1-areas/world.js index dab5623..d830396 100644 --- a/chapter-8/example-1-areas/world.js +++ b/chapter-8/example-1-areas/world.js @@ -13,7 +13,7 @@ const world = { }) }, create: function () { - let dg = new BSPDungeon(80, 50, 4) + let dg = new BSPDungeon(80, 50, 3) let level = dg.toLevelData() dungeon.initialize(this, level) diff --git a/chapter-8/example-2-rooms/bspdungeon.js b/chapter-8/example-2-rooms/bspdungeon.js index 02c0e3a..df2dbb8 100644 --- a/chapter-8/example-2-rooms/bspdungeon.js +++ b/chapter-8/example-2-rooms/bspdungeon.js @@ -44,12 +44,12 @@ class DArea { class DRoom { constructor(area) { - this.x = Math.floor(area.x + (Phaser.Math.Between(1, area.w) / 3)) - this.y = Math.floor(area.y + (Phaser.Math.Between(1, area.h) / 3)) - this.w = area.w - (this.x - area.x) - this.h = area.h - (this.y - area.y) - this.w -= Math.floor(Phaser.Math.Between(1, this.w / 3)) - this.h -= Math.floor(Phaser.Math.Between(1, this.h / 3)) + this.x = area.x+1 + this.y = area.y+1 + this.w = area.w-2 + this.h = area.h-2 + //this.w -= 1; //Math.floor(Phaser.Math.Between(1, this.w / 6)) + //this.h -= 1; //Math.floor(Phaser.Math.Between(1, this.h / 3)) } } diff --git a/chapter-8/example-3-corridors/bspdungeon.js b/chapter-8/example-3-corridors/bspdungeon.js index 476910f..ba4ec98 100644 --- a/chapter-8/example-3-corridors/bspdungeon.js +++ b/chapter-8/example-3-corridors/bspdungeon.js @@ -44,12 +44,16 @@ class DArea { class DRoom { constructor(area) { - this.x = Math.floor(area.x + (Phaser.Math.Between(1, area.w) / 3)) + /* this.x = Math.floor(area.x + (Phaser.Math.Between(1, area.w) / 3)) this.y = Math.floor(area.y + (Phaser.Math.Between(1, area.h) / 3)) this.w = area.w - (this.x - area.x) this.h = area.h - (this.y - area.y) this.w -= Math.floor(Phaser.Math.Between(1, this.w / 3)) this.h -= Math.floor(Phaser.Math.Between(1, this.h / 3)) + */this.x = area.x+1 + this.y = area.y+1 + this.w = area.w-2 + this.h = area.h-2 } } diff --git a/chapter-9/example-4-quest/classes/basicHero.js b/chapter-9/example-4-quest/classes/basicHero.js index 6b1c473..beaf116 100644 --- a/chapter-9/example-4-quest/classes/basicHero.js +++ b/chapter-9/example-4-quest/classes/basicHero.js @@ -3,7 +3,7 @@ import Taggable from "../taggable.js" export default class BasicHero extends Taggable { constructor(x, y) { - super(x, y) + super(x,y) this.name = "The Hero" this.movementPoints = 1 this.actionPoints = 1 @@ -17,7 +17,7 @@ export default class BasicHero extends Taggable { } setEvents() { - dungeon.scene.input.keyboard.addCapture(["SPACE", "UP", "DOWN", "LEFT", "RIGHT"]) + dungeon.scene.input.keyboard.addCapture(["SPACE", "UP","DOWN","LEFT","RIGHT"]) dungeon.scene.input.keyboard.on("keyup", (event) => { if (!this.over()) { this.processInput(event) @@ -147,7 +147,7 @@ export default class BasicHero extends Taggable { this.toggleItem(key - 1) } - + // go down the dungeon if (event.key == "d") { dungeon.goDown() @@ -206,20 +206,17 @@ export default class BasicHero extends Taggable { // Check if entity at destination is an item if (entity && entity.type == "item" && this.actionPoints > 0) { - // Check if inventory is full - if (this.items.length < 10) { - this.items.push(entity) - dungeon.itemPicked(entity) - dungeon.log(`${this.name} picked ${entity.name}: ${entity.description}`) - this.actionPoints -= 1 - } + this.items.push(entity) + dungeon.itemPicked(entity) + dungeon.log(`${this.name} picked ${entity.name}: ${entity.description}`) + this.actionPoints -= 1 } else { newX = oldX newY = oldY } // Check if entity at destination is a stair - if (entity && entity.type == "stairs") { + if (entity && entity.type == "stairs" ) { if (entity.direction == "down") { dungeon.goDown() } else { @@ -338,7 +335,7 @@ export default class BasicHero extends Taggable { if (this.UIstatsText) { this.UIstatsText.setText(`Hp: ${this.healthPoints}\nMp: ${this.movementPoints}\nAp: ${this.actionPoints}`) } - + } cleanup() { diff --git a/chapter-9/example-4-quest/tags/patrolling.js b/chapter-9/example-4-quest/tags/patrolling.js index 1f93015..f41f454 100644 --- a/chapter-9/example-4-quest/tags/patrolling.js +++ b/chapter-9/example-4-quest/tags/patrolling.js @@ -7,7 +7,7 @@ const patrolling = { this.tint = 0xdd00cd if (this.sprite) { - this.sprite.tint = this.tint + this.sprite.tint = this.tin this.sprite.tintFill = true }