From 7899979b2e5774fb104ab669dd7dea04022364db Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Sun, 9 Oct 2016 16:54:40 -0400 Subject: [PATCH 01/21] Add images for spiders to the sprite list --- source/images/sprites/monsters/spider_alpha.png | Bin 0 -> 201 bytes source/images/sprites/monsters/spider_omega.png | Bin 0 -> 191 bytes source/scripts/data/index.js | 4 ++++ 3 files changed, 4 insertions(+) create mode 100755 source/images/sprites/monsters/spider_alpha.png create mode 100755 source/images/sprites/monsters/spider_omega.png diff --git a/source/images/sprites/monsters/spider_alpha.png b/source/images/sprites/monsters/spider_alpha.png new file mode 100755 index 0000000000000000000000000000000000000000..db0f0b643b8d478c08b5cb20883e60903bf7cdb2 GIT binary patch literal 201 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRm!2~304!w#7Qfwtbe!)PRfq_wSp*cH{uJd$p z46*1v8|=t+K!L}*?SK8In+pSWh26Y!BSMhVaBHS3(-E&6?^pgpQA?NPHORzF*9=#$ zxqs<#%Zut8%nVFZR8BS+_WeB}_SoBd?wv__SHT{!ih1^*3`K=ZMBMPkIV+lBcVm%Q~loCIB-IOyd9m literal 0 HcmV?d00001 diff --git a/source/images/sprites/monsters/spider_omega.png b/source/images/sprites/monsters/spider_omega.png new file mode 100755 index 0000000000000000000000000000000000000000..ace01c95c1eac98888d9f7bfdb6a5699f1f3012f GIT binary patch literal 191 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRm!2~304!w#7Qfwtbe!)PRfq_wSp*cH{F7b46 z46*1v8ywAbK!GRw$Zz?ZZ=A19z2PguCZ?(QZK7AJWX{o3L0@KamM%GQjd8-1;8TlP z-+SNk^(eI#%YD(lkrI-=NB+W_oRuZDQPSOImFY|&t;ucLK6UN8AdGt literal 0 HcmV?d00001 diff --git a/source/scripts/data/index.js b/source/scripts/data/index.js index 0dfecce..df68192 100644 --- a/source/scripts/data/index.js +++ b/source/scripts/data/index.js @@ -46,6 +46,10 @@ export default { ALPHA: require("images/sprites/monsters/thief_alpha.png"), OMEGA: require("images/sprites/monsters/thief_omega.png"), }, + SPIDER: { + ALPHA: require("images/sprites/monsters/spider_alpha.png"), + OMEGA: require("images/sprites/monsters/spider_omega.png"), + }, }, EFFECTS: { SLICE: [ From 8650f77df04314649440897890acb1a37b8b89fc Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Sun, 9 Oct 2016 16:55:02 -0400 Subject: [PATCH 02/21] Add a default movement vector to the outOfBound check function --- source/scripts/model/Monster.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/scripts/model/Monster.js b/source/scripts/model/Monster.js index ea3e497..198516f 100644 --- a/source/scripts/model/Monster.js +++ b/source/scripts/model/Monster.js @@ -63,7 +63,7 @@ export default class Monster { movement = movement || {} movement.x = movement.x || 0 movement.y = movement.y || 0 - + // collision with the camera if(this.position.x + movement.x < DATA.FRAME.WIDTH * 0 || this.position.x + movement.x >= DATA.FRAME.WIDTH * 1) { @@ -164,6 +164,7 @@ export default class Monster { return temp } outOfBounds(positionVector) { + positionVector = positionVector || {x: 0, y: 0} if (positionVector.x + this.position.x < 0) { return true } From e9726a039ce9c4d50f69da29ea2f8cb469d8863c Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Sun, 9 Oct 2016 16:55:37 -0400 Subject: [PATCH 03/21] Add a preliminary spider This currently has bat-like movement instead of player-chasing movement. This will be fixed. --- source/scripts/data/monsters.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/scripts/data/monsters.js b/source/scripts/data/monsters.js index 4e6fb91..5b39ef1 100644 --- a/source/scripts/data/monsters.js +++ b/source/scripts/data/monsters.js @@ -225,4 +225,20 @@ export default { } } }, + SPIDER: { + sprite: DATA.SPRITES.MONSTERS.SPIDER, + color: DATA.COLORS.WHITE, + health: 1, + strength: 1, + movement: function () { + var choices = [ + {x: -1, y: -1}, + {x: -1, y: +1}, + {x: +1, y: -1}, + {x: +1, y: +1}, + ] + choices = this.pruneMovement(choices) + return choices[Math.floor((Math.random() * choices.length))] + } + } } From 6140f27cac8d4039400606be62790e2739c2bf24 Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Sun, 9 Oct 2016 16:55:58 -0400 Subject: [PATCH 04/21] Force only spiders to spawn for testing purposes This will be reverted before merging. --- source/scripts/model/MonsterWave.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/scripts/model/MonsterWave.js b/source/scripts/model/MonsterWave.js index 75b3e27..7eb1ae3 100644 --- a/source/scripts/model/MonsterWave.js +++ b/source/scripts/model/MonsterWave.js @@ -13,6 +13,7 @@ // then, enjoy the waves of monsters. :] import DATA from "scripts/data" +import MONSTERS from "scripts/data/monsters.js" import Monster from "scripts/model/Monster.js" export default class MonsterWave { @@ -87,6 +88,7 @@ export default class MonsterWave { // TODO: Update this method to optionally // use weighted randomness if a weight is // assigned to each monster in the wave. + return MONSTERS.SPIDER var index = Math.floor(Math.random() * this.monsters.length) return this.monsters[index] } From ee9fba66fe41dd20afdb2dfd719402cdec69da06 Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Sun, 9 Oct 2016 20:46:13 -0400 Subject: [PATCH 05/21] Add movement for spiders. This will be improved once the proper movement ai is implemented --- source/scripts/data/monsters.js | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/source/scripts/data/monsters.js b/source/scripts/data/monsters.js index 5b39ef1..c59cdd1 100644 --- a/source/scripts/data/monsters.js +++ b/source/scripts/data/monsters.js @@ -231,14 +231,26 @@ export default { health: 1, strength: 1, movement: function () { - var choices = [ - {x: -1, y: -1}, - {x: -1, y: +1}, - {x: +1, y: -1}, - {x: +1, y: +1}, - ] - choices = this.pruneMovement(choices) - return choices[Math.floor((Math.random() * choices.length))] + + var dx = this.game.adventurer.position.x - this.position.x + var dy = this.game.adventurer.position.y - this.position.y + + if (this.outOfBounds(this.position)) { + dx = DATA.FRAME.WIDTH/2 - this.position.x + dy = DATA.FRAME.HEIGHT/2 - this.position.y + } + + var move = {x: 0, y: 0} + if(dx > 0) move.x = +1 + if(dx < 0) move.x = -1 + if(dy > 0) move.y = +1 + if(dy < 0) move.y = -1 + + if (move.x == 0) move.x = 1 + if (move.y == 0) move.y = 1 + + return move + } } } From 4c77518ef8618b3e7147f6bd48a70cb5b8ce3c54 Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Sun, 6 Nov 2016 01:33:34 -0400 Subject: [PATCH 06/21] Correct spider movement --- source/scripts/data/monsters.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/source/scripts/data/monsters.js b/source/scripts/data/monsters.js index c59cdd1..1903f58 100644 --- a/source/scripts/data/monsters.js +++ b/source/scripts/data/monsters.js @@ -235,20 +235,11 @@ export default { var dx = this.game.adventurer.position.x - this.position.x var dy = this.game.adventurer.position.y - this.position.y - if (this.outOfBounds(this.position)) { - dx = DATA.FRAME.WIDTH/2 - this.position.x - dy = DATA.FRAME.HEIGHT/2 - this.position.y + var move = { + x: Math.sign(dx || DATA.FRAME.WIDTH/2 - this.position.x), + y: Math.sign(dy || DATA.FRAME.HEIGHT/2 - this.position.y) } - var move = {x: 0, y: 0} - if(dx > 0) move.x = +1 - if(dx < 0) move.x = -1 - if(dy > 0) move.y = +1 - if(dy < 0) move.y = -1 - - if (move.x == 0) move.x = 1 - if (move.y == 0) move.y = 1 - return move } From a0f82257f41616bd1df6edade13ae12f356b3b78 Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Sun, 6 Nov 2016 01:40:04 -0400 Subject: [PATCH 07/21] Add a Spider test --- source/scripts/tests/SpiderTest.js | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 source/scripts/tests/SpiderTest.js diff --git a/source/scripts/tests/SpiderTest.js b/source/scripts/tests/SpiderTest.js new file mode 100644 index 0000000..0619294 --- /dev/null +++ b/source/scripts/tests/SpiderTest.js @@ -0,0 +1,42 @@ +import Expect from "expect.js" + +import Game from "scripts/model/Game.js" + +import MONSTERS from "scripts/data/monsters.js" +import DATA from "scripts/data/index.js" + +export default function SpiderTest() { + + // We are a testing a game. + + var game = new Game({ + + // A game with an adventurer. + adventurer: { + position: {x: 3, y: 3}, + }, + + // A game with an adventurer and a bat. + + monsters: [ + { + position: {x: 1, y: 1}, + protomonster: MONSTERS.SPIDER + } + ] + + // Also, by purposefully forgetting to + // pass a "wave" to the game, our test + // won't be interrupted by other monsters + // being spawned in. + }) + + Expect(game.monsters[0].position).to.be.eql({x: 1,y: 1}) + game.monsters[0].onAction() + Expect(game.monsters[0].position).to.be.eql({x: 2,y: 2}) + Expect(game.monsters[0].position.x).not.to.be.below(0) + Expect(game.monsters[0].position.y).not.to.be.below(0) + Expect(game.monsters[0].position.x).not.to.be.above(DATA.FRAME.WIDTH) + Expect(game.monsters[0].position.y).not.to.be.above(DATA.FRAME.HEIGHT) + +} From d1ac8e6cd4b8978ae668f8ace38cb55961dc836b Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Sun, 6 Nov 2016 13:26:00 -0500 Subject: [PATCH 08/21] Removed spiders from monsterwave as waves now properly exist --- source/scripts/model/MonsterWave.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/scripts/model/MonsterWave.js b/source/scripts/model/MonsterWave.js index 7eb1ae3..0394606 100644 --- a/source/scripts/model/MonsterWave.js +++ b/source/scripts/model/MonsterWave.js @@ -31,7 +31,7 @@ export default class MonsterWave { if(this.killcount === undefined) { this.killcount = 10 } - + this.message = wave.message this.specialMessage = wave.specialMessage this.isRespawnRoom = wave.isRespawnRoom @@ -41,7 +41,7 @@ export default class MonsterWave { if(this.monsters.length == 0) { return } - + // If attached to a game... if(this.game != undefined) { // If there are still monsters left to kill... @@ -88,7 +88,6 @@ export default class MonsterWave { // TODO: Update this method to optionally // use weighted randomness if a weight is // assigned to each monster in the wave. - return MONSTERS.SPIDER var index = Math.floor(Math.random() * this.monsters.length) return this.monsters[index] } From 94c1e0ef5893b5f96563ff4cbcfc2e88d90b0028 Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Sun, 6 Nov 2016 13:26:38 -0500 Subject: [PATCH 09/21] Rename SPIDER -> NORMAL_SPIDER and add MOTHER_SPIDER --- source/scripts/data/monsters.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/source/scripts/data/monsters.js b/source/scripts/data/monsters.js index 1903f58..c148a4e 100644 --- a/source/scripts/data/monsters.js +++ b/source/scripts/data/monsters.js @@ -225,7 +225,7 @@ export default { } } }, - SPIDER: { + NORMAL_SPIDER: { sprite: DATA.SPRITES.MONSTERS.SPIDER, color: DATA.COLORS.WHITE, health: 1, @@ -243,5 +243,30 @@ export default { return move } - } + }, + MOTHER_SPIDER: { + sprite: DATA.SPRITES.MONSTERS.SPIDER, + color: DATA.COLORS.GREEN, + health: 1, + strength: 1, + movement: function () { + + var dx = this.game.adventurer.position.x - this.position.x + var dy = this.game.adventurer.position.y - this.position.y + + if (this.outOfBounds({x: 0, y: 0})) { + dx = 0 + dy = 0 + } + + var move = { + x: Math.sign(-dx || DATA.FRAME.WIDTH/2 - this.position.x), + y: Math.sign(-dy || DATA.FRAME.HEIGHT/2 - this.position.y) + } + + + return move + + } + }, } From 6e277f60840d594f7c698fc1783090fb0b66c546 Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Sun, 6 Nov 2016 13:35:42 -0500 Subject: [PATCH 10/21] Correct edge cases for spider movement --- source/scripts/data/monsters.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/source/scripts/data/monsters.js b/source/scripts/data/monsters.js index c148a4e..3d007e0 100644 --- a/source/scripts/data/monsters.js +++ b/source/scripts/data/monsters.js @@ -240,6 +240,15 @@ export default { y: Math.sign(dy || DATA.FRAME.HEIGHT/2 - this.position.y) } + if (this.outOfBounds(move)) { + if (this.outOfBounds({x: move.x, y: 0})) { + move.x = -move.x + } + if (this.outOfBounds({x: 0, y: move.y})) { + move.y = -move.y + } + } + return move } @@ -247,14 +256,14 @@ export default { MOTHER_SPIDER: { sprite: DATA.SPRITES.MONSTERS.SPIDER, color: DATA.COLORS.GREEN, - health: 1, - strength: 1, + health: 5, + strength: 0, movement: function () { var dx = this.game.adventurer.position.x - this.position.x var dy = this.game.adventurer.position.y - this.position.y - if (this.outOfBounds({x: 0, y: 0})) { + if (this.outOfBounds()) { dx = 0 dy = 0 } @@ -264,6 +273,14 @@ export default { y: Math.sign(-dy || DATA.FRAME.HEIGHT/2 - this.position.y) } + if (this.outOfBounds(move)) { + if (this.outOfBounds({x: move.x, y: 0})) { + move.x = -move.x + } + if (this.outOfBounds({x: 0, y: move.y})) { + move.y = -move.y + } + } return move From e946946c5c6b3dc395b9ab632bbd7730ec33b1af Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Sun, 6 Nov 2016 13:42:26 -0500 Subject: [PATCH 11/21] Add spawn function to mother spider --- source/scripts/data/monsters.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/scripts/data/monsters.js b/source/scripts/data/monsters.js index 3d007e0..54f8628 100644 --- a/source/scripts/data/monsters.js +++ b/source/scripts/data/monsters.js @@ -258,6 +258,17 @@ export default { color: DATA.COLORS.GREEN, health: 5, strength: 0, + turnCounter: function() { + this.phase = !this.phase + this.turnsUntilSpawn = (this.turnsUntilSpawn || 4) - 1 + if (this.turnsUntilSpawn <= 0) { + this.game.monsters.push(new Monster(this.game, { + protomonster: MONSTERS.NORMAL_SPIDER, + position: {x: this.position.x, y: this.position.y}, + })) + this.game.waves[this.game.adventurer.wave].killcount += 1 + } + }, movement: function () { var dx = this.game.adventurer.position.x - this.position.x From 9408103258768f2d4e3ba07093496ccd492c35ba Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Sun, 6 Nov 2016 13:50:49 -0500 Subject: [PATCH 12/21] Add spider spawn test for mother spider --- source/scripts/tests/SpiderTest.js | 55 +++++++++++++++++++----------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/source/scripts/tests/SpiderTest.js b/source/scripts/tests/SpiderTest.js index 0619294..986e356 100644 --- a/source/scripts/tests/SpiderTest.js +++ b/source/scripts/tests/SpiderTest.js @@ -7,36 +7,51 @@ import DATA from "scripts/data/index.js" export default function SpiderTest() { - // We are a testing a game. - - var game = new Game({ - - // A game with an adventurer. + // Normal Spider test + var game1 = new Game({ adventurer: { position: {x: 3, y: 3}, }, - - // A game with an adventurer and a bat. - monsters: [ { position: {x: 1, y: 1}, - protomonster: MONSTERS.SPIDER + protomonster: MONSTERS.NORMAL_SPIDER } ] + }) - // Also, by purposefully forgetting to - // pass a "wave" to the game, our test - // won't be interrupted by other monsters - // being spawned in. + Expect(game1.monsters[0].position).to.be.eql({x: 1,y: 1}) + game1.monsters[0].onAction() + Expect(game1.monsters[0].position).to.be.eql({x: 2,y: 2}) + + + // Mother Spider test + var game2 = new Game({ + adventurer: { + position: {x: 3, y: 3}, + }, + monsters: [ + { + position: {x: 2, y: 2}, + protomonster: MONSTERS.MOTHER_SPIDER + } + ] }) - Expect(game.monsters[0].position).to.be.eql({x: 1,y: 1}) - game.monsters[0].onAction() - Expect(game.monsters[0].position).to.be.eql({x: 2,y: 2}) - Expect(game.monsters[0].position.x).not.to.be.below(0) - Expect(game.monsters[0].position.y).not.to.be.below(0) - Expect(game.monsters[0].position.x).not.to.be.above(DATA.FRAME.WIDTH) - Expect(game.monsters[0].position.y).not.to.be.above(DATA.FRAME.HEIGHT) + Expect(game2.monsters[0].position).to.be.eql({x: 2,y: 2}) + Expect(game2.monsters.length).to.be.eql(1) + + game2.monsters[0].onAction() + Expect(game2.monsters[0].position).to.be.eql({x: 1,y: 1}) + Expect(game2.monsters.length).to.be.eql(1) + + game2.monsters[0].onAction() + Expect(game2.monsters.length).to.be.eql(1) + + game2.monsters[0].onAction() + Expect(game2.monsters.length).to.be.eql(1) + + game2.monsters[0].onAction() + Expect(game2.monsters.length).to.be.eql(2) } From 76f24a8c6e1c51b1850e25edec84ed3c619a0929 Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Thu, 17 Nov 2016 00:30:47 -0500 Subject: [PATCH 13/21] Attempt at web spiders; not finished --- share.js | 2 +- source/images/sprites/terrain/web.png | Bin 0 -> 230 bytes source/index.js | 8 ++++ source/scripts/data/index.js | 2 + source/scripts/data/monsters.js | 57 ++++++++++++++++++++++++++ source/scripts/model/Adventurer.js | 19 +++++---- source/scripts/model/Monster.js | 19 +++++++-- source/scripts/tests/SpiderTest.js | 12 ------ 8 files changed, 93 insertions(+), 26 deletions(-) create mode 100755 source/images/sprites/terrain/web.png diff --git a/share.js b/share.js index fe09681..6c13f8a 100644 --- a/share.js +++ b/share.js @@ -25,7 +25,7 @@ rimraf("./shares", function() { // Publish the build to the gh-pages branch ghpages.publish(path.join(__dirname, 'shares/'), { add: true, - repo: 'git@github.com:mocsarcade/enchiridion.git', + repo: 'git@github.com:willamin/enchiridion.git', logger: function(message) { console.log(message); } diff --git a/source/images/sprites/terrain/web.png b/source/images/sprites/terrain/web.png new file mode 100755 index 0000000000000000000000000000000000000000..3e3a8ec20fbce0eba8e0535ee1c4318105b5c550 GIT binary patch literal 230 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRm!2~304!w#7Qfwtbe!)PRfq_wSp*cH{p6%)4 z7-G@8HN;csumOj&&;S1^mzi@Ho$8t^bLwO_i%?H5$C1e=++XZ&S+!B!WJOj8uflg0 z1= DATA.FRAME.WIDTH * 1) { @@ -75,20 +75,20 @@ export default class Adventurer { console.log("!!") movement.y = 0 } - + this.bloodscreen = false if(this.grabCount == 0) { // collision with monsters this.game.monsters.forEach((monster) => { - if(!monster.isDead) { + if(!monster.isDead && !monster.isTerrain) { if(this.position.x + movement.x == monster.position.x && this.position.y + movement.y == monster.position.y) { monster.handleAttack(1) - + didSomething = true - + if(movement.x < 0 && movement.y == 0) { this.animation = "attack-westwards" } else if(movement.x > 0 && movement.y == 0) { @@ -124,9 +124,10 @@ export default class Adventurer { movement.x = 0 movement.y = 0 } + console.log(this.game.tiles[key]) } } - + // translation this.position.x += movement.x this.position.y += movement.y @@ -155,7 +156,7 @@ export default class Adventurer { this.grabCount = this.grabCount - 1 this.grabMonster.handleAttack(1) } - + // signaling if(didSomething || movement.x != 0 || movement.y != 0) { this.game.onAction() diff --git a/source/scripts/model/Monster.js b/source/scripts/model/Monster.js index 198516f..33b197d 100644 --- a/source/scripts/model/Monster.js +++ b/source/scripts/model/Monster.js @@ -12,6 +12,11 @@ export default class Monster { this.basesprite = monster.protomonster.sprite || DATA.SPRITES.MONSTERS.SLIME this.sprite = this.pickSprite() this.isSpawned = true + this.opacity = monster.protomonster.opacity || 1 + this.isDead = monster.protomonster.isDead || false + this.stack = monster.protomonster.stack || 0 + this.hasAlternateSprite = monster.protomonster.hasAlternateSprite || true + this.isTerrain = monster.protomonster.isTerrain || false this.game = game @@ -38,13 +43,19 @@ export default class Monster { this.health = monster.protomonster.health || 1 - + if (monster.protomonster.onSpawn) { + monster.protomonster.onSpawn() + } } pickSprite() { - if(this.phase == true) { - return this.basesprite.ALPHA + if (this.hasAlternateSprite) { + if(this.phase == true) { + return this.basesprite.ALPHA + } else { + return this.basesprite.OMEGA + } } else { - return this.basesprite.OMEGA + return this.basesprite } } onAction() { diff --git a/source/scripts/tests/SpiderTest.js b/source/scripts/tests/SpiderTest.js index 986e356..381df46 100644 --- a/source/scripts/tests/SpiderTest.js +++ b/source/scripts/tests/SpiderTest.js @@ -39,19 +39,7 @@ export default function SpiderTest() { }) Expect(game2.monsters[0].position).to.be.eql({x: 2,y: 2}) - Expect(game2.monsters.length).to.be.eql(1) - game2.monsters[0].onAction() Expect(game2.monsters[0].position).to.be.eql({x: 1,y: 1}) - Expect(game2.monsters.length).to.be.eql(1) - - game2.monsters[0].onAction() - Expect(game2.monsters.length).to.be.eql(1) - - game2.monsters[0].onAction() - Expect(game2.monsters.length).to.be.eql(1) - - game2.monsters[0].onAction() - Expect(game2.monsters.length).to.be.eql(2) } From 62be4a610572f95ed4f24f821352252d6e36a48e Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Mon, 21 Nov 2016 01:09:28 -0500 Subject: [PATCH 14/21] Fix web spiders! --- source/scripts/data/monsters.js | 9 ++++-- source/scripts/model/Monster.js | 50 +++++++++++++++++------------ source/scripts/model/MonsterWave.js | 2 +- 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/source/scripts/data/monsters.js b/source/scripts/data/monsters.js index 09c1971..f33ca3e 100644 --- a/source/scripts/data/monsters.js +++ b/source/scripts/data/monsters.js @@ -304,14 +304,17 @@ export default { isTerrain: true, health: 10, stack: -100, + strength: 0, movement: function() {}, hasAlternateSprite: false, + turnCounter: function() { + this.phase = true + }, grabCounter: function() { this.turnCount = this.turnCount || 0 - //the adventurer cannot be grabbed by another monster and he cannot grab him more than once if(this.game.adventurer.grabCount == 0 && this.turnCount == 0) { - this.turnCount = this.turnCount + 1 - this.game.adventurer.grabCount += 3 + this.turnCount += 1 + this.game.adventurer.grabCount += 1 this.game.adventurer.grabMonster = this } } diff --git a/source/scripts/model/Monster.js b/source/scripts/model/Monster.js index 33b197d..8727d9f 100644 --- a/source/scripts/model/Monster.js +++ b/source/scripts/model/Monster.js @@ -15,7 +15,11 @@ export default class Monster { this.opacity = monster.protomonster.opacity || 1 this.isDead = monster.protomonster.isDead || false this.stack = monster.protomonster.stack || 0 - this.hasAlternateSprite = monster.protomonster.hasAlternateSprite || true + if (monster.protomonster.hasAlternateSprite == undefined) { + this.hasAlternateSprite = true + } else { + this.hasAlternateSprite = monster.protomonster.hasAlternateSprite + } this.isTerrain = monster.protomonster.isTerrain || false this.game = game @@ -101,28 +105,32 @@ export default class Monster { // collsiion with adventurer if(this.position.x + movement.x == this.game.adventurer.position.x && this.position.y + movement.y == this.game.adventurer.position.y) { - this.game.adventurer.beAttacked() - this.grabCounter() - if(movement.x < 0 && movement.y == 0) { - this.animation = "attack-westwards" - } else if(movement.x > 0 && movement.y == 0) { - this.animation = "attack-eastwards" - } else if(movement.x == 0 && movement.y < 0) { - this.animation = "attack-northwards" - } else if(movement.x == 0 && movement.y > 0) { - this.animation = "attack-southwards" + if (!this.isTerrain) { + this.game.adventurer.beAttacked() } - this.game.add("effects", new Effect({ - sprite: new AnimatedSprite({ - images: DATA.SPRITES.EFFECTS.SLASH, - isLoop: false, - timing: 20, - }), - position: { - x: this.position.x + movement.x, - y: this.position.y + movement.y, + this.grabCounter() + if (!this.isTerrain) { + if(movement.x < 0 && movement.y == 0) { + this.animation = "attack-westwards" + } else if(movement.x > 0 && movement.y == 0) { + this.animation = "attack-eastwards" + } else if(movement.x == 0 && movement.y < 0) { + this.animation = "attack-northwards" + } else if(movement.x == 0 && movement.y > 0) { + this.animation = "attack-southwards" } - })) + this.game.add("effects", new Effect({ + sprite: new AnimatedSprite({ + images: DATA.SPRITES.EFFECTS.SLASH, + isLoop: false, + timing: 20, + }), + position: { + x: this.position.x + movement.x, + y: this.position.y + movement.y, + } + })) + } movement.x = 0 movement.y = 0 } diff --git a/source/scripts/model/MonsterWave.js b/source/scripts/model/MonsterWave.js index 0394606..d18e064 100644 --- a/source/scripts/model/MonsterWave.js +++ b/source/scripts/model/MonsterWave.js @@ -96,7 +96,7 @@ export default class MonsterWave { } getCapacity() { return this.game.monsters.reduce((capacity, monster) => { - return capacity + (monster.isDead ? 0 : 1) + return capacity + ((monster.isDead || monster.isTerrain) ? 0 : 1) }, 0) } get capacity() { From 45f5fef84e4e493164ba770704761b2319c24409 Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Mon, 21 Nov 2016 01:10:49 -0500 Subject: [PATCH 15/21] Mother spiders shouldn't increase the killcount upon spawning new spiders --- source/scripts/data/monsters.js | 1 - 1 file changed, 1 deletion(-) diff --git a/source/scripts/data/monsters.js b/source/scripts/data/monsters.js index f33ca3e..91665f3 100644 --- a/source/scripts/data/monsters.js +++ b/source/scripts/data/monsters.js @@ -266,7 +266,6 @@ export default { protomonster: MONSTERS.NORMAL_SPIDER, position: {x: this.position.x, y: this.position.y}, })) - this.game.waves[this.game.adventurer.wave].killcount += 1 } }, movement: function () { From 07cceb79ff620b7eadef1085ea2f2264e1bd2024 Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Mon, 21 Nov 2016 01:29:02 -0500 Subject: [PATCH 16/21] Put a max on the number of children a mother spider can spawn at a time --- source/index.js | 2 +- source/scripts/data/monsters.js | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/source/index.js b/source/index.js index 2c270ee..9efd804 100644 --- a/source/index.js +++ b/source/index.js @@ -40,7 +40,7 @@ state.game = new Game({ capacity: 1, killcount: 5, monsters: [ - MONSTERS.WEB_SPIDER, + MONSTERS.MOTHER_SPIDER, ], message: "Room 0: spider test", }, diff --git a/source/scripts/data/monsters.js b/source/scripts/data/monsters.js index 91665f3..5763ee2 100644 --- a/source/scripts/data/monsters.js +++ b/source/scripts/data/monsters.js @@ -261,11 +261,20 @@ export default { turnCounter: function() { this.phase = !this.phase this.turnsUntilSpawn = (this.turnsUntilSpawn || 4) - 1 - if (this.turnsUntilSpawn <= 0) { - this.game.monsters.push(new Monster(this.game, { + this.childCount = this.childCount || 0 + + if (this.turnsUntilSpawn <= 0 && this.childCount < 3) { + var child = new Monster(this.game, { protomonster: MONSTERS.NORMAL_SPIDER, position: {x: this.position.x, y: this.position.y}, - })) + }) + var mother = this + child.onDeath = function() { + mother.childCount -= 1 + this.game.wave.killcount += 1 + } + this.game.monsters.push(child) + this.childCount += 1 } }, movement: function () { From 8899fcf4c3294377c6db7b31f544cbae85b81704 Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Mon, 21 Nov 2016 01:33:46 -0500 Subject: [PATCH 17/21] Fix spawned spider sprite render bug --- source/scripts/model/Monster.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/scripts/model/Monster.js b/source/scripts/model/Monster.js index 8727d9f..2aff178 100644 --- a/source/scripts/model/Monster.js +++ b/source/scripts/model/Monster.js @@ -10,7 +10,6 @@ export default class Monster { this.key = "monster" + "-" + ShortID.generate() this.color = monster.protomonster.color || DATA.COLORS.PINK this.basesprite = monster.protomonster.sprite || DATA.SPRITES.MONSTERS.SLIME - this.sprite = this.pickSprite() this.isSpawned = true this.opacity = monster.protomonster.opacity || 1 this.isDead = monster.protomonster.isDead || false @@ -20,6 +19,7 @@ export default class Monster { } else { this.hasAlternateSprite = monster.protomonster.hasAlternateSprite } + this.sprite = this.pickSprite() this.isTerrain = monster.protomonster.isTerrain || false this.game = game From 205e65e6bd3811ceffa26d583dc96309b4cec24e Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Mon, 21 Nov 2016 01:39:17 -0500 Subject: [PATCH 18/21] Change the mother spider sprite --- .../sprites/monsters/mother_spider_alpha.png | Bin 0 -> 231 bytes .../sprites/monsters/mother_spider_omega.png | Bin 0 -> 231 bytes source/scripts/data/index.js | 4 ++++ source/scripts/data/monsters.js | 2 +- 4 files changed, 5 insertions(+), 1 deletion(-) create mode 100755 source/images/sprites/monsters/mother_spider_alpha.png create mode 100755 source/images/sprites/monsters/mother_spider_omega.png diff --git a/source/images/sprites/monsters/mother_spider_alpha.png b/source/images/sprites/monsters/mother_spider_alpha.png new file mode 100755 index 0000000000000000000000000000000000000000..cfe7eccfac2b0f5c1d19181f26a36a6616f4e1bd GIT binary patch literal 231 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRm!2~304!w#7Qfwtbe!)PRfq_wSp*cH{p5y7_ z7-G@8HYl3!umK12mf!N0_t0iPzjd dRLkVQ_lOm9VJzf1=);T3K0RSLzS^WS2 literal 0 HcmV?d00001 diff --git a/source/images/sprites/monsters/mother_spider_omega.png b/source/images/sprites/monsters/mother_spider_omega.png new file mode 100755 index 0000000000000000000000000000000000000000..ec5e104fa0e5a4f11d8dc68695a572f48f3f03e2 GIT binary patch literal 231 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRm!2~304!w#7Qfwtbe!)PRfq_wSp*cH{p5y7_ z7-G@8HYkwKS&?IL%6I!uH`t{&Mb(~9Jtol-#KmQN z{a54f6uu_jU#pi%s)!W4)%UcWlW|HjbcL*-;6yk3%P0P>bGT|QdgqD&=iGmLs&;nt z=VUbq7KLT{^K-6mT4H=%!1j38zTbP>J=cZ&c>O)DmL+!iyvo!st0!!k<-dIYi%^w2 c@yCO!7+38n)xTXjQ3K>)Pgg&ebxsLQ03JJ7=l}o! literal 0 HcmV?d00001 diff --git a/source/scripts/data/index.js b/source/scripts/data/index.js index ca26d4f..b711dce 100644 --- a/source/scripts/data/index.js +++ b/source/scripts/data/index.js @@ -50,6 +50,10 @@ export default { ALPHA: require("images/sprites/monsters/spider_alpha.png"), OMEGA: require("images/sprites/monsters/spider_omega.png"), }, + MOTHER_SPIDER: { + ALPHA: require("images/sprites/monsters/mother_spider_alpha.png"), + OMEGA: require("images/sprites/monsters/mother_spider_omega.png"), + }, }, EFFECTS: { SLICE: [ diff --git a/source/scripts/data/monsters.js b/source/scripts/data/monsters.js index 5763ee2..8e9c5e0 100644 --- a/source/scripts/data/monsters.js +++ b/source/scripts/data/monsters.js @@ -254,7 +254,7 @@ export default { } }, MOTHER_SPIDER: { - sprite: DATA.SPRITES.MONSTERS.SPIDER, + sprite: DATA.SPRITES.MONSTERS.MOTHER_SPIDER, color: DATA.COLORS.GREEN, health: 5, strength: 0, From c99c41cf5efccacb86abe14fb7ea2496e687487d Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Mon, 21 Nov 2016 01:46:55 -0500 Subject: [PATCH 19/21] Add diagonal attack animations for monsters --- source/index.css | 24 ++++++++++++++++++++++++ source/scripts/model/Monster.js | 8 ++++++++ 2 files changed, 32 insertions(+) diff --git a/source/index.css b/source/index.css index d09d055..1e94d9a 100644 --- a/source/index.css +++ b/source/index.css @@ -39,6 +39,30 @@ html { 100% {transform: translateX(0px)} } +@keyframes attack-southeastwards { + 0% {transform: translate(0px,0px)} + 50% {transform: translate(+7px,+7px)} + 100% {transform: translate(0px,0px)} +} + +@keyframes attack-northeastwards { + 0% {transform: translate(0px,0px)} + 50% {transform: translate(+7px,-7px)} + 100% {transform: translate(0px,0px)} +} + +@keyframes attack-southeastwards { + 0% {transform: translate(0px,0px)} + 50% {transform: translate(-7px,+7px)} + 100% {transform: translate(0px,0px)} +} + +@keyframes attack-southwestwards { + 0% {transform: translate(0px,0px)} + 50% {transform: translate(-7px,-7px)} + 100% {transform: translate(0px,0px)} +} + @function strip-unit($number) { @if type-of($number) == 'number' and not unitless($number) { @return $number / ($number * 0 + 1); diff --git a/source/scripts/model/Monster.js b/source/scripts/model/Monster.js index 2aff178..ecaf7eb 100644 --- a/source/scripts/model/Monster.js +++ b/source/scripts/model/Monster.js @@ -118,6 +118,14 @@ export default class Monster { this.animation = "attack-northwards" } else if(movement.x == 0 && movement.y > 0) { this.animation = "attack-southwards" + } else if(movement.x > 0 && movement.y > 0) { + this.animation = "attack-southeastwards" + } else if(movement.x > 0 && movement.y < 0) { + this.animation = "attack-northeastwards" + } else if(movement.x < 0 && movement.y > 0) { + this.animation = "attack-southeastwards" + } else if(movement.x < 0 && movement.y < 0) { + this.animation = "attack-northwestwards" } this.game.add("effects", new Effect({ sprite: new AnimatedSprite({ From 0ebbbe859012a6bfc1c13c79e260b69d14fd449d Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Mon, 21 Nov 2016 01:50:47 -0500 Subject: [PATCH 20/21] Add test rooms for spider testing --- source/index.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/source/index.js b/source/index.js index 9efd804..da8e4af 100644 --- a/source/index.js +++ b/source/index.js @@ -39,10 +39,26 @@ state.game = new Game({ { capacity: 1, killcount: 5, + monsters: [ + MONSTERS.NORMAL_SPIDER, + ], + message: "Room 0.1: spider test", + }, + { + capacity: 1, + killcount: 2, monsters: [ MONSTERS.MOTHER_SPIDER, ], - message: "Room 0: spider test", + message: "Room 0.2: mother spider test", + }, + { + capacity: 1, + killcount: 2, + monsters: [ + MONSTERS.WEB_SPIDER, + ], + message: "Room 0.3: web spider test", }, // orcs { From 4c2aaa43f44e06dd0226313ea1073abc727d3e38 Mon Sep 17 00:00:00 2001 From: Will Lewis Date: Mon, 21 Nov 2016 02:01:31 -0500 Subject: [PATCH 21/21] Clean up a few testing changes --- share.js | 2 +- source/index.js | 24 ------------------------ 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/share.js b/share.js index 6c13f8a..fe09681 100644 --- a/share.js +++ b/share.js @@ -25,7 +25,7 @@ rimraf("./shares", function() { // Publish the build to the gh-pages branch ghpages.publish(path.join(__dirname, 'shares/'), { add: true, - repo: 'git@github.com:willamin/enchiridion.git', + repo: 'git@github.com:mocsarcade/enchiridion.git', logger: function(message) { console.log(message); } diff --git a/source/index.js b/source/index.js index da8e4af..b71f4d8 100644 --- a/source/index.js +++ b/source/index.js @@ -36,30 +36,6 @@ state.game = new Game({ "Move ↑↑↑ to the next room." ].join("\n") }, - { - capacity: 1, - killcount: 5, - monsters: [ - MONSTERS.NORMAL_SPIDER, - ], - message: "Room 0.1: spider test", - }, - { - capacity: 1, - killcount: 2, - monsters: [ - MONSTERS.MOTHER_SPIDER, - ], - message: "Room 0.2: mother spider test", - }, - { - capacity: 1, - killcount: 2, - monsters: [ - MONSTERS.WEB_SPIDER, - ], - message: "Room 0.3: web spider test", - }, // orcs { capacity: function() {