FAZA 2: Fix player going off-terrain - sync player with terrain container offset

This commit is contained in:
2025-12-06 18:12:15 +01:00
parent 6e92e89f74
commit 1c1ee97b2c
2 changed files with 24 additions and 9 deletions

View File

@@ -21,11 +21,15 @@ class GameScene extends Phaser.Scene {
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
// Terrain offset
this.terrainOffsetX = width / 2;
this.terrainOffsetY = 100;
this.terrainContainer = this.terrainSystem.render(this.terrainOffsetX, this.terrainOffsetY);
// Dodaj igralca - spawn na sredini mape S TERRAIN OFFSETOM
console.log('👤 Initializing player...');
this.player = new Player(this, 50, 50);
this.player = new Player(this, 50, 50, this.terrainOffsetX, this.terrainOffsetY);
// Kamera sledi igralcu
this.cameras.main.startFollow(this.player.sprite, true, 0.1, 0.1);