This commit is contained in:
2025-12-08 00:18:56 +01:00
parent b36cc981d6
commit 7834aee111
10 changed files with 466 additions and 43 deletions

View File

@@ -38,6 +38,7 @@ class BootScene extends Phaser.Scene {
create() {
console.log('✅ BootScene: Complete!');
console.log('🎨 Pixel Art Mode: pixelArt=true, roundPixels=true (NEAREST filtering)');
window.gameState.currentScene = 'BootScene';
// Global Constants for Sprites

View File

@@ -50,10 +50,57 @@ class GameScene extends Phaser.Scene {
// Initial force update to render active tiles before first frame
this.terrainSystem.updateCulling(this.cameras.main);
// FAZA 14: Spawn Ruin (Town Project) at fixed location near player
console.log('🏚️ Spawning Ruin & Arena...');
// INITIALIZE FARM AREA (Starter Zone @ 20,20)
this.initializeFarmWorld();
// CITY CONTENT: Ruins, Chests, Spawners
console.log('🏚️ Generating City Content...');
// Main Ruins
this.terrainSystem.placeStructure(55, 55, 'ruin');
this.terrainSystem.placeStructure(75, 75, 'arena');
this.terrainSystem.placeStructure(65, 65, 'ruin');
this.terrainSystem.placeStructure(75, 75, 'ruin');
this.terrainSystem.placeStructure(60, 70, 'ruin');
this.terrainSystem.placeStructure(70, 60, 'ruin');
// Arena (Boss battle area)
this.terrainSystem.placeStructure(75, 55, 'arena');
// Treasure Chests (scattered in ruins)
this.terrainSystem.placeStructure(56, 56, 'chest');
this.terrainSystem.placeStructure(66, 66, 'chest');
this.terrainSystem.placeStructure(76, 76, 'chest');
// Zombie Spawners (in city)
this.terrainSystem.placeStructure(58, 68, 'spawner');
this.terrainSystem.placeStructure(72, 62, 'spawner');
// CESTE (ROADS) - povezava med farmo (20,20) in mestom (65,65)
console.log('🛣️ Building Roads...');
// Horizontalna cesta od farme
for (let x = 20; x <= 45; x++) {
this.terrainSystem.tiles[22][x].type = 'pavement';
this.terrainSystem.tiles[22][x].sprite.setTexture('dirt'); // Uporablj dirt kot "cesto"
this.terrainSystem.tiles[22][x].sprite.setTint(0x808080); // Siva barva
}
// Vertikalna cesta do mesta
for (let y = 22; y <= 65; y++) {
this.terrainSystem.tiles[y][45].type = 'pavement';
this.terrainSystem.tiles[y][45].sprite.setTexture('dirt');
this.terrainSystem.tiles[y][45].sprite.setTint(0x808080);
}
// Horizontalna cesta do mesta
for (let x = 45; x <= 65; x++) {
this.terrainSystem.tiles[65][x].type = 'pavement';
this.terrainSystem.tiles[65][x].sprite.setTexture('dirt');
this.terrainSystem.tiles[65][x].sprite.setTint(0x808080);
}
// SIGNPOSTS - navigacijske table
console.log('🪧 Placing Signposts...');
this.terrainSystem.placeStructure(23, 22, 'signpost_city'); // Pri farmi "→ City"
this.terrainSystem.placeStructure(65, 64, 'signpost_farm'); // Pri mestu "← Farm"
this.terrainSystem.placeStructure(45, 40, 'signpost_both'); // Na križišču
// Initialize Pathfinding (Worker)
console.log('🗺️ Initializing Pathfinding...');
@@ -87,8 +134,17 @@ class GameScene extends Phaser.Scene {
this.npcs.push(zombie);
}
// Kamera sledi igralcu
this.cameras.main.startFollow(this.player.sprite, true, 1.0, 1.0);
// ELITE ZOMBIES v City območju (65,65 ± 15)
console.log('👹 Spawning ELITE ZOMBIES in City...');
for (let i = 0; i < 15; i++) { // Veliko elite zombijev!
const randomX = Phaser.Math.Between(50, 80); // City area
const randomY = Phaser.Math.Between(50, 80);
const elite = new NPC(this, randomX, randomY, this.terrainOffsetX, this.terrainOffsetY, 'elite_zombie');
this.npcs.push(elite);
}
// Kamera sledi igralcu z gladko interpolacijo (lerp 0.1)
this.cameras.main.startFollow(this.player.sprite, true, 0.1, 0.1);
// Nastavi deadzone (100px border)
this.cameras.main.setDeadzone(100, 100);
@@ -381,4 +437,46 @@ class GameScene extends Phaser.Scene {
loadGame() {
if (this.saveSystem) this.saveSystem.loadGame();
}
initializeFarmWorld() {
console.log('🌾 Initializing Farm Area (Starter Zone)...');
const farmX = 20; // Farm center
const farmY = 20;
const farmRadius = 8;
// 1. Clear farm area (odstrani drevesa in kamne)
for (let x = farmX - farmRadius; x <= farmX + farmRadius; x++) {
for (let y = farmY - farmRadius; y <= farmY + farmRadius; y++) {
if (x >= 0 && x < 100 && y >= 0 && y < 100) {
const key = `${x},${y}`;
// Remove trees and rocks in farm area
if (this.terrainSystem.decorationsMap.has(key)) {
this.terrainSystem.removeDecoration(x, y);
}
// Make it grass or dirt
this.terrainSystem.tiles[y][x].type = { name: 'grass', color: 0x228B22 };
this.terrainSystem.tiles[y][x].sprite.setTint(0x228B22);
}
}
}
// 2. Place starter resources (chest s semeni)
this.terrainSystem.placeStructure(farmX + 3, farmY + 3, 'chest');
// 3. Place fence around farm (optional)
const fencePositions = [
[farmX - farmRadius, farmY - farmRadius],
[farmX + farmRadius, farmY - farmRadius],
[farmX - farmRadius, farmY + farmRadius],
[farmX + farmRadius, farmY + farmRadius]
];
fencePositions.forEach(([fx, fy]) => {
if (fx >= 0 && fx < 100 && fy >= 0 && fy < 100) {
this.terrainSystem.placeStructure(fx, fy, 'fence');
}
});
console.log('✅ Farm Area Initialized at (20,20)');
}
}

View File

@@ -51,6 +51,7 @@ class PreloadScene extends Phaser.Scene {
this.load.image('tree_dead_new', 'assets/tree_dead_new.png');
this.load.image('flowers_new', 'assets/flowers_new.png');
this.load.image('merchant_new', 'assets/merchant_new.png');
this.load.image('elite_zombie', 'assets/elite_zombie.png');
this.load.image('hill_sprite', 'assets/hill_sprite.png');
this.load.image('fence', 'assets/fence.png');
this.load.image('gravestone', 'assets/gravestone.png');
@@ -123,6 +124,7 @@ class PreloadScene extends Phaser.Scene {
'rock_2',
'rock_small',
'merchant_new',
'elite_zombie',
'tree_dead_new',
'flowers_new',
'hill_sprite',