// Game Scene - Glavna igralna scena class GameScene extends Phaser.Scene { constructor() { super({ key: 'GameScene' }); this.terrainSystem = null; this.terrainContainer = null; this.player = null; } create() { console.log('🎮 GameScene: Initialized!'); window.gameState.currentScene = 'GameScene'; const width = this.cameras.main.width; const height = this.cameras.main.height; // Setup kamere this.cameras.main.setBackgroundColor('#1a1a2e'); // Inicializiraj terrain sistem - 100x100 mapa console.log('🌍 Initializing terrain...'); this.terrainSystem = new TerrainSystem(this, 100, 100); this.terrainSystem.generate(); this.terrainContainer = this.terrainSystem.render(width / 2, 100); // Dodaj igralca - spawn na sredini mape console.log('👤 Initializing player...'); this.player = new Player(this, 50, 50); // Kamera sledi igralcu this.cameras.main.startFollow(this.player.sprite, true, 0.1, 0.1); // Kamera kontrole this.setupCamera(); // UI elementi this.createUI(); // Debug info this.debugText = this.add.text(10, 10, '', { fontFamily: 'Courier New', fontSize: '12px', fill: '#ffffff', backgroundColor: '#000000', padding: { x: 5, y: 3 } }); this.debugText.setScrollFactor(0); this.debugText.setDepth(1000); // FPS counter this.fpsText = this.add.text(10, height - 30, 'FPS: 60', { fontFamily: 'Courier New', fontSize: '14px', fill: '#00ff41' }); this.fpsText.setScrollFactor(0); this.fpsText.setDepth(1000); console.log('✅ GameScene ready - FAZA 2!'); } setupCamera() { const cam = this.cameras.main; // Zoom kontrole (Mouse Wheel) this.input.on('wheel', (pointer, gameObjects, deltaX, deltaY, deltaZ) => { const zoomSpeed = 0.001; const newZoom = Phaser.Math.Clamp( cam.zoom - deltaY * zoomSpeed, 0.3, 2.0 ); cam.setZoom(newZoom); }); // Pan kontrole (Right click + drag) - DISABLED za FAZA 2 // Player movement sedaj uporablja WASD // Q/E za zoom this.zoomKeys = this.input.keyboard.addKeys({ zoomIn: Phaser.Input.Keyboard.KeyCodes.Q, zoomOut: Phaser.Input.Keyboard.KeyCodes.E }); } createUI() { const width = this.cameras.main.width; // Naslov const title = this.add.text(width / 2, 20, 'FAZA 2: Igralec in Gibanje', { fontFamily: 'Courier New', fontSize: '20px', fill: '#00ff41', fontStyle: 'bold' }); title.setOrigin(0.5, 0); title.setScrollFactor(0); title.setDepth(1000); // Kontrole info const controlsText = this.add.text(width - 10, 10, 'Kontrole:\n' + 'WASD - Gibanje igralca\n' + 'Q/E - Zoom\n' + 'Mouse Wheel - Zoom', { fontFamily: 'Courier New', fontSize: '11px', fill: '#888888', backgroundColor: '#000000', padding: { x: 5, y: 3 }, align: 'right' } ); controlsText.setOrigin(1, 0); controlsText.setScrollFactor(0); controlsText.setDepth(1000); } update(time, delta) { // Update player if (this.player) { this.player.update(delta); } // Update FPS if (this.fpsText) { this.fpsText.setText(`FPS: ${Math.round(this.game.loop.actualFps)}`); } // Zoom controls const cam = this.cameras.main; if (this.zoomKeys) { if (this.zoomKeys.zoomIn.isDown) { cam.setZoom(Phaser.Math.Clamp(cam.zoom + 0.01, 0.3, 2.0)); } if (this.zoomKeys.zoomOut.isDown) { cam.setZoom(Phaser.Math.Clamp(cam.zoom - 0.01, 0.3, 2.0)); } } // 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` + `Zoom: ${cam.zoom.toFixed(2)}\n` + `Player Grid: (${playerPos.x}, ${playerPos.y})\n` + `Player Screen: (${Math.round(screenPos.x)}, ${Math.round(screenPos.y)})` ); } } }