Phase 28 Session 2: Biome-based terrain generation active!

CRITICAL UPDATE - Switched to chunk-based biome rendering:

Flat2DTerrainSystem.js changes:
- generate() method now checks for BiomeSystem availability
- If BiomeSystem & ChunkManager exist  use chunk-based generation
- If not available  fallback to old Map2DData system
- createBiomeBackground() creates simple base layer
- Chunks are rendered on-demand via ChunkManager

Flow:
1. Terrain system checks: biomeSystem && chunkManager
2. If YES  Skip Map2DData, use chunks
3. Create green background (24000x24000px)
4. ChunkManager loads 9 chunks around player
5. Each chunk renders with biome-specific tiles

Benefits:
- Only renders visible chunks (9 instead of 250k tiles!)
- Biome-specific tiles per chunk
- Dynamic loading as player moves
- Fallback to old system if needed

Status: Ready for biome visualization test!
Next: Reload game and see biomes!

Files modified: 1 (Flat2DTerrainSystem.js)
This commit is contained in:
2025-12-15 17:14:36 +01:00
parent 3ac82204e9
commit 18fa7af648

View File

@@ -35,21 +35,59 @@ class Flat2DTerrainSystem {
// Create textures first // Create textures first
this.createTileTextures(); this.createTileTextures();
// Load map data // 🌍 PHASE 28: Use BiomeSystem if available
if (typeof Map2DData !== 'undefined') { if (this.biomeSystem && this.chunkManager) {
this.tiles = Map2DData.generateMap(); console.log('🌍 Using BiomeSystem for chunk-based terrain generation');
console.log('✅ Map data generated:', this.tiles.length, 'rows'); // Biome-based generation will happen via ChunkManager
// No need to generate full map here!
// Create simple grass background as fallback
this.createBiomeBackground();
} else { } else {
console.error('❌ Map2DData not loaded!'); // Fallback to old Map2DData system
this.createFallbackMap(); console.log('📊 Using Map2DData for terrain generation (fallback)');
// Load map data
if (typeof Map2DData !== 'undefined') {
this.tiles = Map2DData.generateMap();
console.log('✅ Map data generated:', this.tiles.length, 'rows');
} else {
console.error('❌ Map2DData not loaded!');
this.createFallbackMap();
}
// Render the old-style map
this.renderMap();
} }
// Render the map
this.renderMap();
console.log('✅ Flat 2D map ready!'); console.log('✅ Flat 2D map ready!');
} }
// 🌍 PHASE 28: Create simple biome-aware background
createBiomeBackground() {
const size = this.tileSize;
const mapWidth = this.width * size;
const mapHeight = this.height * size;
console.log('🎨 Creating biome-aware background...');
// Create solid background (will be covered by chunks)
const background = this.scene.add.rectangle(0, 0, mapWidth, mapHeight, 0x3CB371);
background.setOrigin(0, 0);
background.setDepth(0);
// Create containers for chunks
this.pathsLayer = this.scene.add.container(0, 0);
this.pathsLayer.setDepth(2);
this.decorLayer = this.scene.add.container(0, 0);
this.decorLayer.setDepth(3);
this.groundLayer = background;
console.log('✅ Biome background created, ready for chunks');
}
createTileTextures() { createTileTextures() {
// 🎨 Create SOLID, OPAQUE tiles (no transparency!) // 🎨 Create SOLID, OPAQUE tiles (no transparency!)