diff --git a/assets/level1.json b/assets/level1.json index 64092fb..2af9dec 100644 --- a/assets/level1.json +++ b/assets/level1.json @@ -1,37 +1,25 @@ { "compressionlevel":-1, - "height":9, - "infinite":true, + "height":13, + "infinite":false, "layers":[ { - "chunks":[ - { - "data":[2, 1, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, - 2, 1, 2, 1, 1, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, - 2, 1, 1, 1, 2, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, - 2, 2, 2, 2, 2, 2, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - "height":16, - "width":16, - "x":0, - "y":0 - }], - "height":16, + "data":[2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 12, 0, 0, + 2, 1, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 12, 0, 0, + 2, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 1, 2, 12, 0, 0, + 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 12, 0, 0, + 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 12, 0, 0, + 2, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 12, 0, 0, + 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 12, 0, 0, + 2, 1, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 2, 12, 0, 0, + 2, 1, 2, 1, 2, 2, 1, 1, 2, 2, 2, 1, 2, 12, 0, 0, + 2, 1, 2, 1, 2, 2, 2, 1, 1, 1, 1, 1, 2, 12, 0, 0, + 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 12, 0, 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 12, 0, 0, + 2684354572, 2684354572, 2684354572, 2684354572, 2684354572, 2684354572, 2684354572, 2684354572, 2684354572, 2684354572, 2684354572, 2684354572, 2684354572, 2684354572, 0, 0], + "height":13, "id":1, "name":"main", "opacity":1, - "startx":0, - "starty":0, "type":"tilelayer", "visible":true, "width":16, @@ -39,35 +27,23 @@ "y":0 }, { - "chunks":[ - { - "data":[0, 0, 16, 0, 16, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 16, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 16, 16, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 16, 0, 0, 0, 0, + 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + "height":13, "id":2, "name":"platforms", "opacity":1, - "startx":0, - "starty":0, "type":"tilelayer", "visible":true, "width":16, diff --git a/assets/terrain.png b/assets/terrain.png index 2cb5785..fdf3248 100644 Binary files a/assets/terrain.png and b/assets/terrain.png differ diff --git a/assets/terrain.psd b/assets/terrain.psd index ab62e81..828f141 100644 Binary files a/assets/terrain.psd and b/assets/terrain.psd differ diff --git a/assets/tilesets/level1.tmx b/assets/tilesets/level1.tmx index 8d2b4ea..1e4cf74 100644 --- a/assets/tilesets/level1.tmx +++ b/assets/tilesets/level1.tmx @@ -1,5 +1,5 @@ - + @@ -11,48 +11,38 @@ - + - -2,1,2,2,2,2,2,2,0,0,0,0,0,0,0,0, -2,1,2,1,1,1,2,2,0,0,0,0,0,0,0,0, -2,1,1,1,2,1,1,2,0,0,0,0,0,0,0,0, -2,2,2,2,2,2,1,2,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - +2,1,2,2,2,2,2,2,2,2,2,2,2,12,0,0, +2,1,2,1,1,1,2,2,2,2,2,2,2,12,0,0, +2,1,1,1,2,1,1,2,2,1,1,1,2,12,0,0, +2,2,2,2,2,2,1,2,2,1,2,2,2,12,0,0, +2,2,2,2,2,2,1,2,2,1,2,2,2,12,0,0, +2,1,1,1,1,1,1,2,2,1,1,1,2,12,0,0, +2,1,2,2,2,2,2,2,2,2,2,1,2,12,0,0, +2,1,2,1,1,1,1,2,2,2,2,1,2,12,0,0, +2,1,2,1,2,2,1,1,2,2,2,1,2,12,0,0, +2,1,2,1,2,2,2,1,1,1,1,1,2,12,0,0, +2,1,1,1,2,2,2,2,2,2,2,2,2,12,0,0, +2,2,2,2,2,2,2,2,2,2,2,2,2,12,0,0, +2684354572,2684354572,2684354572,2684354572,2684354572,2684354572,2684354572,2684354572,2684354572,2684354572,2684354572,2684354572,2684354572,2684354572,0,0 + - + - 0,0,16,0,16,0,16,0,0,0,0,0,0,0,0,0, -0,0,16,0,0,0,16,0,0,0,0,0,0,0,0,0, +0,0,16,0,0,0,16,0,0,0,16,0,0,0,0,0, 16,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0, -0,16,16,0,16,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,16,16,0,16,0,0,0,16,0,0,0,0,0,0,0, +0,0,0,16,0,0,0,0,0,0,16,16,0,0,0,0, +0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0, +0,0,16,0,0,16,0,0,0,0,16,0,16,0,0,0, +16,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0, +0,0,16,0,16,16,0,0,0,0,16,0,0,0,0,0, +0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,16,0,0,16,0,0,0,0, +0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - - + diff --git a/src/levels/level.js b/src/levels/level.js index faa9ba4..ec4dabf 100644 --- a/src/levels/level.js +++ b/src/levels/level.js @@ -57,23 +57,23 @@ export class Level extends Phaser.Scene { } addControls() { - this.input.on('wheel', (pointer, gameObjects, deltaX, deltaY) => { - const zoomSpeed = 0.1; - if (deltaY < 0) { - // Zoom in - this.cameras.main.zoom += zoomSpeed; - } else if (deltaY > 0) { - // Zoom out - this.cameras.main.zoom -= zoomSpeed; - } + // this.input.on('wheel', (pointer, gameObjects, deltaX, deltaY) => { + // const zoomSpeed = 0.1; + // if (deltaY < 0) { + // // Zoom in + // this.cameras.main.zoom += zoomSpeed; + // } else if (deltaY > 0) { + // // Zoom out + // this.cameras.main.zoom -= zoomSpeed; + // } - // Limit zoom range to prevent extreme zoom levels - this.cameras.main.zoom = Phaser.Math.Clamp(this.cameras.main.zoom, 0.5, 2); + // // Limit zoom range to prevent extreme zoom levels + // this.cameras.main.zoom = Phaser.Math.Clamp(this.cameras.main.zoom, 0.5, 2); - // Zoom toward mouse position - const worldPoint = this.input.activePointer.positionToCamera(this.cameras.main); - this.cameras.main.centerOn(worldPoint.x, worldPoint.y); - }); + // // Zoom toward mouse position + // const worldPoint = this.input.activePointer.positionToCamera(this.cameras.main); + // this.cameras.main.centerOn(worldPoint.x, worldPoint.y); + // }); // Add camera panning functionality this.input.on('pointerdown', (pointer) => { diff --git a/src/support/enemies.js b/src/support/enemies.js index 2d13917..cfbeaa1 100644 --- a/src/support/enemies.js +++ b/src/support/enemies.js @@ -12,6 +12,10 @@ export class Enemies { this.speedLow = ENEMIES_CONFIG[type].speedLow; this.speedHigh = ENEMIES_CONFIG[type].speedHigh; this.baseSprite = ENEMIES_CONFIG[type].spriteStart; + this.spawnRange = { + low: 500, + high: 4000 + } this.spawnEnemy(); } @@ -24,7 +28,7 @@ export class Enemies { const spawnY = (this.y * 200) + 100 + randY; // Randomize Spawn Time a bit - this.scene.time.delayedCall(Phaser.Math.Between(0,2000), () => { + this.scene.time.delayedCall(Phaser.Math.Between(this.spawnRange.low, this.spawnRange.high), () => { // Create enemy and store reference const enemy = this.scene.add.sprite(spawnX, spawnY, ENEMIES_CONFIG[this.type].spriteSheet, ENEMIES_CONFIG[this.type].spriteStart); diff --git a/src/support/interfaceManager.js b/src/support/interfaceManager.js index c05dee5..4d80d01 100644 --- a/src/support/interfaceManager.js +++ b/src/support/interfaceManager.js @@ -4,7 +4,7 @@ export class InterfaceManager { constructor(scene) { this.scene = scene; - this.gold = 100; + this.gold = 150; this.cores = 20; this.interfaceOpen = false; this.selectedTower = false; @@ -56,15 +56,15 @@ export class InterfaceManager { this.scene.tweens.add({ targets: this.intTop, y: 50, - duration: 2000, - delay: 2000, + duration: 500, + delay: 500, ease: 'Back.easeOut', onComplete: () => { this.scene.tweens.add({ targets: [this.coreText, this.goldText, this.intCore], angle: 360, alpha: 1, - duration: 1000, + duration: 500, onComplete: () => { this.scene.tweens.add({ targets: this.intCore, @@ -103,14 +103,14 @@ export class InterfaceManager { this.scene.tweens.add({ targets: this.intMain, y: 1150, - duration: 2000, - delay: 2000, + duration: 500, + delay: 500, ease: 'Back.easeOut', onComplete: () => { this.scene.tweens.add({ targets: [this.interfaceText, this.upLeft, this.upRight], alpha: 1, - duration: 1000, + duration: 500, onComplete: () => { this.scene.tweens.add({ targets: [this.upLeft, this.upRight], @@ -266,7 +266,7 @@ export class InterfaceManager { .setOrigin(0.5) .setScrollFactor(0); slot.add(slotBack); - slotBack.setInteractive(); + //slotBack.setInteractive(); slotBack.on('pointerdown', () => { this.selectTower(type); }); @@ -384,9 +384,10 @@ export class InterfaceManager { } // Snap to current mouse position + const levelCam = this.scene.levelScene.cameras.main; const mouse = this.scene.input.activePointer; - const worldX = mouse.worldX; - const worldY = mouse.worldY; + const worldX = mouse.position.x + levelCam.scrollX; + const worldY = mouse.position.y + levelCam.scrollY; // Convert world coordinates to tile coordinates const tileX = Math.floor(worldX / 200); // Assuming 200px tile width @@ -405,9 +406,10 @@ export class InterfaceManager { update(time, delta) { if (this.selectedTower) { // Snap to current mouse position + const levelCam = this.scene.levelScene.cameras.main; const mouse = this.scene.input.activePointer; - const worldX = mouse.worldX; - const worldY = mouse.worldY; + const worldX = mouse.position.x + levelCam.scrollX; + const worldY = mouse.position.y + levelCam.scrollY; // Convert world coordinates to tile coordinates const tileX = Math.floor(worldX / 200); // Assuming 200px tile width @@ -418,9 +420,10 @@ export class InterfaceManager { x: tileX, y: tileY }; + // Convert back to world position for proper snapping - const snappedX = tileX * 200 + 100; // Center the tower on the tile (assuming 200px tiles) - const snappedY = tileY * 200 + 100; + const snappedX = tileX * 200 + 100 - levelCam.scrollX; // Center the tower on the tile (assuming 200px tiles) + const snappedY = tileY * 200 + 100 - levelCam.scrollY; this.selectedTower.setPosition(snappedX, snappedY); @@ -444,11 +447,6 @@ export class InterfaceManager { } } } - - if (mouse.rightButtonDown()) { - this.selectedTower.destroy(); - this.selectedTower = false; - } } } } \ No newline at end of file diff --git a/src/support/waveConfig.js b/src/support/waveConfig.js index 17bb968..8083936 100644 --- a/src/support/waveConfig.js +++ b/src/support/waveConfig.js @@ -4,8 +4,8 @@ export const WAVE_CONFIG = { //Spawn Point spawnX: 1, spawnY: 0, - endX: 6, - endY: 3, + endX: 11, + endY: 2, // Wave 1: { // Schedule @@ -40,6 +40,22 @@ export const WAVE_CONFIG = { basic1: 5, basic2: 4 } + }, + // Wave + 3: { + // Schedule + 1: { + begin: 0, + basic2: 5 + }, + 2: { + begin: 15, + basic2: 6 + }, + 3: { + begin: 30, + basic2: 8 + } } } } \ No newline at end of file diff --git a/src/support/waveManager.js b/src/support/waveManager.js index 4c21602..d984e46 100644 --- a/src/support/waveManager.js +++ b/src/support/waveManager.js @@ -150,7 +150,7 @@ export class WaveManager { this.waveTimer += delta; if (this.waveTimer >= this.waveStart && this.levelActive === true && this.waveActive===true) { - console.log('Wave',this.wave,'Schedule',this.schedule); + //console.log('Wave',this.wave,'Schedule',this.schedule); // Make path synchronous this.makePath().then(() => { // Spawn enemies after path is ready @@ -172,13 +172,13 @@ export class WaveManager { spawnSchedule() { if (this.scheduleInfo.hasOwnProperty('basic1')) { - console.log('Spawn',this.scheduleInfo.basic1,'Basic1 enemies'); + //console.log('Spawn',this.scheduleInfo.basic1,'Basic1 enemies'); for (let e = 0; e < this.scheduleInfo.basic1; e++) { const enemy = new Enemies(this.scene, 'basic1', this.spawnX, this.spawnY, this.path); } } if (this.scheduleInfo.hasOwnProperty('basic2')) { - console.log('Spawn',this.scheduleInfo.basic2,'Basic2 enemies'); + //console.log('Spawn',this.scheduleInfo.basic2,'Basic2 enemies'); for (let e = 0; e < this.scheduleInfo.basic2; e++) { const enemy = new Enemies(this.scene, 'basic2', this.spawnX, this.spawnY, this.path); } @@ -193,7 +193,7 @@ export class WaveManager { const width = this.scene.levelMap.width; const height = this.scene.levelMap.height; const grid = []; - + console.log('width', width, 'height', height); // Create a grid based on collision data for (let y = 0; y < height; y++) { grid[y] = [];