// Game Scene - Glavna igralna scena class GameScene extends Phaser.Scene { constructor() { super({ key: 'GameScene' }); this.terrainSystem = null; this.terrainContainer = 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); // 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 1!'); } 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) this.input.on('pointermove', (pointer) => { if (pointer.rightButtonDown()) { cam.scrollX -= (pointer.x - pointer.prevPosition.x) / cam.zoom; cam.scrollY -= (pointer.y - pointer.prevPosition.y) / cam.zoom; } }); // WASD za kamera kontrolo (alternativa) this.cursors = this.input.keyboard.addKeys({ up: Phaser.Input.Keyboard.KeyCodes.W, down: Phaser.Input.Keyboard.KeyCodes.S, left: Phaser.Input.Keyboard.KeyCodes.A, right: Phaser.Input.Keyboard.KeyCodes.D, 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 1: Generacija Terena', { 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 - Pan\n' + 'Q/E - Zoom\n' + 'Mouse Wheel - Zoom\n' + 'Right Click - Pan', { 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 FPS if (this.fpsText) { this.fpsText.setText(`FPS: ${Math.round(this.game.loop.actualFps)}`); } // Kamera movement (WASD) const cam = this.cameras.main; const panSpeed = 5; if (this.cursors) { if (this.cursors.up.isDown) { cam.scrollY -= panSpeed; } if (this.cursors.down.isDown) { cam.scrollY += panSpeed; } if (this.cursors.left.isDown) { cam.scrollX -= panSpeed; } if (this.cursors.right.isDown) { cam.scrollX += panSpeed; } // Zoom if (this.cursors.zoomIn.isDown) { cam.setZoom(Phaser.Math.Clamp(cam.zoom + 0.01, 0.3, 2.0)); } if (this.cursors.zoomOut.isDown) { cam.setZoom(Phaser.Math.Clamp(cam.zoom - 0.01, 0.3, 2.0)); } } // Debug info update if (this.debugText) { const pointer = this.input.activePointer; const worldX = Math.round(pointer.worldX); const worldY = Math.round(pointer.worldY); this.debugText.setText( `FAZA 1 - Terrain System\n` + `Zoom: ${cam.zoom.toFixed(2)}\n` + `Camera: (${Math.round(cam.scrollX)}, ${Math.round(cam.scrollY)})\n` + `Mouse: (${worldX}, ${worldY})` ); } } }