FAZA 3: Add 3 NPCs with random walk AI (zombie, villager, merchant)
This commit is contained in:
@@ -5,6 +5,7 @@ class GameScene extends Phaser.Scene {
|
||||
this.terrainSystem = null;
|
||||
this.terrainContainer = null;
|
||||
this.player = null;
|
||||
this.npcs = []; // Array za NPCje
|
||||
}
|
||||
|
||||
create() {
|
||||
@@ -31,6 +32,16 @@ class GameScene extends Phaser.Scene {
|
||||
console.log('👤 Initializing player...');
|
||||
this.player = new Player(this, 50, 50, this.terrainOffsetX, this.terrainOffsetY);
|
||||
|
||||
// Dodaj 3 NPCje - random pozicije
|
||||
console.log('🧟 Initializing NPCs...');
|
||||
const npcTypes = ['zombie', 'villager', 'merchant'];
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const randomX = Phaser.Math.Between(20, 80);
|
||||
const randomY = Phaser.Math.Between(20, 80);
|
||||
const npc = new NPC(this, randomX, randomY, this.terrainOffsetX, this.terrainOffsetY, npcTypes[i]);
|
||||
this.npcs.push(npc);
|
||||
}
|
||||
|
||||
// Kamera sledi igralcu
|
||||
this.cameras.main.startFollow(this.player.sprite, true, 0.1, 0.1);
|
||||
|
||||
@@ -60,7 +71,7 @@ class GameScene extends Phaser.Scene {
|
||||
this.fpsText.setScrollFactor(0);
|
||||
this.fpsText.setDepth(1000);
|
||||
|
||||
console.log('✅ GameScene ready - FAZA 2!');
|
||||
console.log('✅ GameScene ready - FAZA 3!');
|
||||
}
|
||||
|
||||
setupCamera() {
|
||||
@@ -91,7 +102,7 @@ class GameScene extends Phaser.Scene {
|
||||
const width = this.cameras.main.width;
|
||||
|
||||
// Naslov
|
||||
const title = this.add.text(width / 2, 20, 'FAZA 2: Igralec in Gibanje', {
|
||||
const title = this.add.text(width / 2, 20, 'FAZA 3: NPC-ji in Dekoracije', {
|
||||
fontFamily: 'Courier New',
|
||||
fontSize: '20px',
|
||||
fill: '#00ff41',
|
||||
@@ -127,6 +138,11 @@ class GameScene extends Phaser.Scene {
|
||||
this.player.update(delta);
|
||||
}
|
||||
|
||||
// Update NPCs
|
||||
for (const npc of this.npcs) {
|
||||
npc.update(delta);
|
||||
}
|
||||
|
||||
// Update FPS
|
||||
if (this.fpsText) {
|
||||
this.fpsText.setText(`FPS: ${Math.round(this.game.loop.actualFps)}`);
|
||||
@@ -146,13 +162,12 @@ class GameScene extends Phaser.Scene {
|
||||
// Debug info update
|
||||
if (this.debugText && this.player) {
|
||||
const playerPos = this.player.getPosition();
|
||||
const screenPos = this.player.getScreenPosition();
|
||||
|
||||
this.debugText.setText(
|
||||
`FAZA 2 - Player Movement\n` +
|
||||
`FAZA 3 - NPCs & Decorations\n` +
|
||||
`Zoom: ${cam.zoom.toFixed(2)}\n` +
|
||||
`Player Grid: (${playerPos.x}, ${playerPos.y})\n` +
|
||||
`Player Screen: (${Math.round(screenPos.x)}, ${Math.round(screenPos.y)})`
|
||||
`Player: (${playerPos.x}, ${playerPos.y})\n` +
|
||||
`NPCs: ${this.npcs.length}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user