diff --git a/assets/NNDungeon.json b/assets/NNDungeon.json index 943452c..8daf5ac 100644 --- a/assets/NNDungeon.json +++ b/assets/NNDungeon.json @@ -260,6 +260,50 @@ "x":0, "y":0 }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 83, 84, 0, 0, 0, 0, 90, 0, 0, 0, 83, 84, 0, 0, + 0, 50, 93, 94, 10, 0, 20, 0, 0, 20, 30, 10, 93, 94, 50, 0, + 0, 0, 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, 40, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 90, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0], + "height":16, + "width":16, + "x":16, + "y":0 + }, + { + "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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1300, "y":3000 }, - { - "gid":241, - "height":100, - "id":21, - "name":"", - "properties":[ - { - "name":"NNBoss", - "type":"bool", - "value":true - }, - { - "name":"garbage", - "type":"bool", - "value":true - }, - { - "name":"health", - "type":"int", - "value":3 - }, - { - "name":"patrolY", - "type":"int", - "value":350 - }], - "rotation":0, - "type":"", - "visible":true, - "width":100, - "x":6050.49833041819, - "y":346.500238511687 - }, { "gid":301, "height":200, @@ -814,8 +847,111 @@ "type":"", "visible":true, "width":200, - "x":4400, - "y":400 + "x":4300, + "y":300 + }, + { + "gid":217, + "height":100, + "id":23, + "name":"", + "properties":[ + { + "name":"fastShot", + "type":"bool", + "value":true + }, + { + "name":"garbage", + "type":"bool", + "value":true + }, + { + "name":"patrolX", + "type":"int", + "value":-1000 + }, + { + "name":"speed", + "type":"int", + "value":75 + }], + "rotation":0, + "type":"", + "visible":true, + "width":100, + "x":5700, + "y":1200 + }, + + { + "gid":213, + "height":100, + "id":24, + "name":"", + "properties":[ + { + "name":"fire", + "type":"int", + "value":300 + }, + { + "name":"patrolY", + "type":"int", + "value":-400 + }], + "rotation":0, + "type":"", + "visible":true, + "width":100, + "x":6200, + "y":1300 + }, + { + "gid":201, + "height":100, + "id":25, + "name":"", + "properties":[ + { + "name":"fire", + "type":"int", + "value":800 + }, + { + "name":"patrolX", + "type":"int", + "value":-700 + }], + "rotation":0, + "type":"", + "visible":true, + "width":100, + "x":4100, + "y":1600 + }, + { + "gid":213, + "height":100, + "id":26, + "name":"", + "properties":[ + { + "name":"fire", + "type":"int", + "value":500 + }, + { + "name":"patrolY", + "type":"int", + "value":300 + }], + "rotation":0, + "type":"", + "visible":true, + "width":100, + "x":3500, + "y":1300 }], "opacity":1, "type":"objectgroup", @@ -881,7 +1017,7 @@ "y":0 }], "nextlayerid":6, - "nextobjectid":23, + "nextobjectid":28, "orientation":"orthogonal", "renderorder":"right-down", "tiledversion":"1.11.2", diff --git a/assets/heart-upgrade.png b/assets/heart-upgrade.png new file mode 100644 index 0000000..ae3fdea Binary files /dev/null and b/assets/heart-upgrade.png differ diff --git a/raw/NNDungeon.tmx b/raw/NNDungeon.tmx index ca233d2..c13f1e5 100644 --- a/raw/NNDungeon.tmx +++ b/raw/NNDungeon.tmx @@ -1,5 +1,5 @@ - + @@ -367,6 +367,9 @@ + + + @@ -570,6 +573,42 @@ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,83,84,0,0,0,0,90,0,0,0,83,84,0,0, +0,50,93,94,10,0,20,0,0,20,30,10,93,94,50,0, +0,0,0,0,0,0,0,79,0,0,0,0,40,0,0,0, +0,0,0,0,0,0,0,0,0,100,0,0,0,0,0,0, +0,0,0,0,0,0,0,90,0,0,0,0,0,0,0,0, +0,88,89,0,0,0,0,0,0,0,0,0,0,40,0,0 + + +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0,0,0,0,0,139,0,0,0,0,0,0,0,160,0,0, @@ -770,12 +827,38 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/raw/Tile-Project-Legends.tiled-session b/raw/Tile-Project-Legends.tiled-session index 2b4d472..6bc8007 100644 --- a/raw/Tile-Project-Legends.tiled-session +++ b/raw/Tile-Project-Legends.tiled-session @@ -7,6 +7,7 @@ "expandedProjectPaths": [ "." ], + "file.lastUsedOpenFilter": "All Files (*)", "fileStates": { "": { "scaleInDock": 1, @@ -14,19 +15,22 @@ }, "NNDungeon.tmx": { "expandedObjectLayers": [ - 5, - 3 + 3, + 5 ], - "scale": 0.33, - "selectedLayer": 0, + "scale": 0.5, + "selectedLayer": 1, "viewCenter": { - "x": 3200, - "y": 2401.5151515151515 + "x": 2369, + "y": 1644 } }, "NNDungeon.tmx#99boy-tiles": { "scaleInDock": 1 }, + "NNDungeon.tmx#boss-tiles": { + "scaleInDock": 1 + }, "NNDungeon.tmx#dungeon-tiles": { "scaleInDock": 0.33 }, @@ -42,11 +46,11 @@ "scaleInDock": 1 }, "gulch.tmx": { - "scale": 0.125, - "selectedLayer": 0, + "scale": 0.5, + "selectedLayer": 3, "viewCenter": { - "x": 3480, - "y": 2396 + "x": 5589, + "y": 1076 } }, "gulch.tmx#99boy-tiles": { @@ -68,20 +72,19 @@ "map.tileWidth": 100, "map.width": 16, "openFiles": [ - "gulch.tmx", - "NNDungeon.tmx", - "gluch.tmx" - ], - "project": "Tile-Project-Legends.tiled-project", - "property.type": "bool", - "recentFiles": [ - "gluch.tmx", "NNDungeon.tmx", "gulch.tmx" ], + "project": "Tile-Project-Legends.tiled-project", + "property.type": "int", + "recentFiles": [ + "NNDungeon.tmx", + "gulch.tmx", + "gluch.tmx" + ], "tileset.embedInMap": true, "tileset.tileSize": { - "height": 100, - "width": 100 + "height": 200, + "width": 200 } } diff --git a/src/characters/99boy.js b/src/characters/99boy.js index 7996a57..4a93d92 100644 --- a/src/characters/99boy.js +++ b/src/characters/99boy.js @@ -27,11 +27,13 @@ export class NNBoy extends Phaser.GameObjects.Sprite { this.garbage = false; this.onPause = false; this.health = 1; + this.takingDamage = false; + this.boss = false; // Create animations this.anims.create({ key: 'walk99', - frames: this.anims.generateFrameNumbers('99boy-tiles', { start: frame, end: frame+1 }), + frames: this.anims.generateFrameNumbers(texture, { start: frame, end: frame+1 }), frameRate: 5, repeat: -1 }); @@ -101,33 +103,87 @@ export class NNBoy extends Phaser.GameObjects.Sprite { // Example: Enemy taking damage takeDamage() { + if (this.takingDamage === true) { + return; + } + + this.takingDamage = true; + + // Set takingDamage back to false after 2000ms + this.scene.time.delayedCall(500, () => { + this.takingDamage = false; + }); + if (this.health === 1) { - let dropHeart = Math.floor(Math.random() * this.dropHeartOneIn); - if (dropHeart === 1) { - let heart = this.scene.physics.add.image(this.x, this.y, 'heart-full').setScale(.5); - this.scene.hearts.add(heart); + + if (this.boss === true) { + //BOSS DEFEAT + this.shoots = false; + this.garbage = false; + this.onPatrol = false; + this.anims.stop('walk99'); + this.onPause = true; + this.setTexture('boss-tiles', 2); this.scene.tweens.add({ - targets: heart, - scale: 0.8, - duration: 1000, + targets: this, + scale: 1.5, ease: 'Power1', yoyo: true, - repeat: -1 + repeat: 2, + duration: 200, + onComplete: () => { + this.setTexture('boss-tiles', 3); + this.scene.tweens.add({ + targets: this, + ease: 'Power1', + scale: 1.1, + duration: 200, + onComplete: () => { + this.setTexture('boss-tiles', 4); + this.scene.tweens.add({ + targets: this, + ease: 'Power1', + scale: 0, + duration: 2000, + delay: 2000, + onComplete: () => { + this.destroy(); + } + }); + } + }); + } + }); + } else { + this.scene.game.playerData.score += 1; + //REGULAR ENEMY DEFEAT + let dropHeart = Math.floor(Math.random() * this.dropHeartOneIn); + if (dropHeart === 1) { + let heart = this.scene.physics.add.image(this.x, this.y, 'heart-full').setScale(.5); + this.scene.hearts.add(heart); + this.scene.tweens.add({ + targets: heart, + scale: 0.8, + duration: 1000, + ease: 'Power1', + yoyo: true, + repeat: -1 + }); + } + // Create a tween that scales the enemy's body on Y-axis to 10 + let variance = Math.floor(Math.random() * 2); + this.scene.sound.play('99boy-defeat-'+variance); + this.scene.tweens.add({ + targets: this, + scaleY: .2, + duration: 200, // Duration of the animation in milliseconds + ease: 'Power1', + onComplete: () => { + // Destroy the enemy after the animation completes + this.destroy(); + } }); } - // Create a tween that scales the enemy's body on Y-axis to 10 - let variance = Math.floor(Math.random() * 2); - this.scene.sound.play('99boy-defeat-'+variance); - this.scene.tweens.add({ - targets: this, - scaleY: .2, - duration: 200, // Duration of the animation in milliseconds - ease: 'Power1', - onComplete: () => { - // Destroy the enemy after the animation completes - this.destroy(); - } - }); } else { this.body.setVelocity(0, 0); this.health --; @@ -141,6 +197,10 @@ export class NNBoy extends Phaser.GameObjects.Sprite { this.speed += 200; this.bottleReloadVariance = 1000; } + if (this.boss === true) { + this.anims.stop('walk99'); + this.setTexture('boss-tiles', 2); + } } } @@ -231,10 +291,14 @@ export class NNBoy extends Phaser.GameObjects.Sprite { // update(time, delta) { + if (this.takingDamage === true) { + this.body.setVelocity(0, 0); + return; + } if (this.onPatrol === true) { this.patrol(); + this.anims.play('walk99', true); } - this.anims.play('walk99', true); const camera = this.scene.cameras.main; diff --git a/src/characters/player.js b/src/characters/player.js index 317d0fb..bbda2f5 100644 --- a/src/characters/player.js +++ b/src/characters/player.js @@ -13,7 +13,7 @@ export class Player extends Phaser.GameObjects.Sprite { this.healthText; this.healthImages; this.numHearts = 3; - this.maxHearts = 3; + this.maxHearts = scene.game.playerData.maxHearts; this.normalVelocityX = 260; this.inventory = []; this.facing = 'south'; @@ -125,6 +125,8 @@ export class Player extends Phaser.GameObjects.Sprite { return; } + let axeAngle = this.body.angle + this.isAttacking = true; this.pauseMove = true; @@ -152,7 +154,7 @@ export class Player extends Phaser.GameObjects.Sprite { velocY = 1500; } else if (this.facing === 'south') { offsetY = -100; - rotate = 270; + rotate = 9; velocY = -1500; } @@ -215,7 +217,7 @@ export class Player extends Phaser.GameObjects.Sprite { .setShadow(3,3, '#333', 5) .setScrollFactor(0); this.updateHealth(); - this.livesText = this.scene.add.text(16, 64, 'Lives:', { fontSize: '36px', fill: '#FFF' }) + this.livesText = this.scene.add.text(16, 64, 'Score: '+this.scene.game.playerData.score, { fontSize: '36px', fill: '#FFF' }) .setShadow(3,3, '#333', 5) .setScrollFactor(0); } @@ -225,6 +227,7 @@ export class Player extends Phaser.GameObjects.Sprite { if (this.isTakingDamage) { return; } + this.isTakingDamage = true; this.scene.sound.play('player-damage'); this.scene.tweens.add({ @@ -271,14 +274,16 @@ export class Player extends Phaser.GameObjects.Sprite { // Knockback // Reset taking damage state after a delay - this.scene.time.delayedCall(500, () => { + this.scene.time.delayedCall(1000, () => { this.isTakingDamage = false; this.pauseMove = false; }); } addHealth(amount) { - if (this.numHearts < 3) { + // this.maxHearts ++; + // this.scene.game.playerData.maxHearts = this.maxHearts; + if (this.numHearts < this.maxHearts) { this.numHearts += 1; this.updateHealth(); this.scene.sound.play('health-pickup'); @@ -292,13 +297,9 @@ export class Player extends Phaser.GameObjects.Sprite { if (this.healthImages) { this.healthImages.destroy(true); } - if (this.lifeImages) { - this.lifeImages.destroy(true); - } + this.healthImages = this.scene.add.group(); - this.lifeImages = this.scene.add.group(); let startX = 170; - let startLivesX = 165 // Add full hearts for (let i = 0; i < this.numHearts; i++) { @@ -307,16 +308,10 @@ export class Player extends Phaser.GameObjects.Sprite { } // Add empty hearts for the remaining slots - for (let i = this.numHearts; i < 3; i++) { + for (let i = this.numHearts; i < this.maxHearts; i++) { this.healthImages.add(this.scene.add.image(startX, 15, 'heart-empty').setOrigin(0, 0).setScale(.5).setScrollFactor(0)); startX += 48; } - - // Add Lives - for (let i = 0; i < this.numLives; i++) { - this.lifeImages.add(this.scene.add.image(startLivesX, 64, 'life').setOrigin(0, 0).setScale(.5).setScrollFactor(0)); - startLivesX += 48; - } } addItemToInventory(itemKey) { diff --git a/src/globalState.js b/src/globalState.js index ea152ac..906eb63 100644 --- a/src/globalState.js +++ b/src/globalState.js @@ -14,9 +14,7 @@ export class GlobalState { } set hearts(value) { - if (value < 0) { - throw new Error("Hearts cannot be less than 0"); - } + if (value < 0) throw new Error("Hearts cannot be less than 0"); this.playerData.hearts = value; } @@ -25,9 +23,7 @@ export class GlobalState { } set maxHearts(value) { - if (value < 0) { - throw new Error("Max hearts cannot be less than 0"); - } + if (value < 0) throw new Error("Max hearts cannot be less than 0"); this.playerData.maxHearts = value; } @@ -36,31 +32,25 @@ export class GlobalState { } set score(value) { - if (value < 0) { - throw new Error("Score cannot be less than 0"); - } + if (value < 0) throw new Error("Score cannot be less than 0"); this.playerData.score = value; } get inventory() { - return [...this.playerData.inventory]; // Return a copy to prevent external modification + return [...this.playerData.inventory]; // Return a copy } set inventory(value) { - if (!Array.isArray(value)) { - throw new Error("Inventory must be an array"); - } + if (!Array.isArray(value)) throw new Error("Inventory must be an array"); this.playerData.inventory = value; } get upgrades() { - return [...this.playerData.upgrades]; // Return a copy to prevent external modification + return [...this.playerData.upgrades]; // Return a copy } set upgrades(value) { - if (!Array.isArray(value)) { - throw new Error("Upgrades must be an array"); - } + if (!Array.isArray(value)) throw new Error("Upgrades must be an array"); this.playerData.upgrades = value; } } \ No newline at end of file diff --git a/src/main.js b/src/main.js index 4356092..4f62dce 100644 --- a/src/main.js +++ b/src/main.js @@ -1,9 +1,6 @@ import { MenuScene } from './scenes/MenuScene.js'; import { Gulch } from './scenes/gulch.js'; import { NNDungeon } from './scenes/NNDungeon.js'; -// import { L2Scene } from './scenes/L2Scene.js'; -// import { L3Scene } from './scenes/L3Scene.js'; - const config = { type: Phaser.AUTO, @@ -21,10 +18,17 @@ const config = { }, scene: [ - //MenuScene, - //Gulch, + MenuScene, + Gulch, NNDungeon ] }; -new Phaser.Game(config); \ No newline at end of file +const game = new Phaser.Game(config); + +game.playerData = { + score: 0, + maxHearts: 3, + startGulchX: 950, + startGulchY: 4250, +} \ No newline at end of file diff --git a/src/scenes/NNDungeon.js b/src/scenes/NNDungeon.js index eefb41c..6e9bcc2 100644 --- a/src/scenes/NNDungeon.js +++ b/src/scenes/NNDungeon.js @@ -30,8 +30,8 @@ export class NNDungeon extends Phaser.Scene { frameHeight: 100 }); this.load.spritesheet('boss-tiles', 'assets/boss-tiles.png', { - frameWidth: 100, - frameHeight: 100 + frameWidth: 200, + frameHeight: 200 }); this.load.spritesheet('99Dungeon-tiles', 'assets/dungeon-tiles.png', { frameWidth: 100, @@ -62,8 +62,8 @@ export class NNDungeon extends Phaser.Scene { //const zoneLayer = gulchMap.getObjectLayer('zone'); // Add a player - //this.player = new Player(this, 2400, 3450); - this.player = new Player(this, 3550, 350); + this.player = new Player(this, 2400, 3450); + //this.player = new Player(this, 3550, 350); this.player.healthBars(true, 1, 3); // zoneLayer.objects.forEach(object => { @@ -95,6 +95,7 @@ export class NNDungeon extends Phaser.Scene { }); enemiesLayer.objects.forEach(object => { let a99Boy; + console.log(object.gid); if (object.gid > 300) { a99Boy = this.enemies.create(object.x-50, object.y-50, 'boss-tiles', object.gid-301); } else { @@ -133,7 +134,7 @@ export class NNDungeon extends Phaser.Scene { a99Boy.bottleReloadVariance = 500; } if (prop.name === 'NNBoss' && prop.value === true) { - a99Boy.tiles = 'boss-tiles' + a99Boy.boss = true; } if (prop.name === 'health') { a99Boy.health = prop.value; diff --git a/src/scenes/gulch.js b/src/scenes/gulch.js index 2cb0f41..62a2e94 100644 --- a/src/scenes/gulch.js +++ b/src/scenes/gulch.js @@ -53,7 +53,7 @@ export class Gulch extends Phaser.Scene { const zoneLayer = gulchMap.getObjectLayer('zone'); // Add a player - this.player = new Player(this, 950, 4250); + this.player = new Player(this, this.game.playerData.startGulchX, this.game.playerData.startGulchY); this.player.healthBars(true, 1, 3); zoneLayer.objects.forEach(object => { @@ -69,6 +69,7 @@ export class Gulch extends Phaser.Scene { runChildUpdate: true }); enemiesLayer.objects.forEach(object => { + let a99Boy = this.enemies.create(object.x-50, object.y-50, '99boy-tiles', object.gid-101); if (object.properties) { object.properties.forEach(prop => { if (prop.name === 'patrolX') {