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:
@@ -35,21 +35,59 @@ class Flat2DTerrainSystem {
|
||||
// Create textures first
|
||||
this.createTileTextures();
|
||||
|
||||
// Load map data
|
||||
if (typeof Map2DData !== 'undefined') {
|
||||
this.tiles = Map2DData.generateMap();
|
||||
console.log('✅ Map data generated:', this.tiles.length, 'rows');
|
||||
// 🌍 PHASE 28: Use BiomeSystem if available
|
||||
if (this.biomeSystem && this.chunkManager) {
|
||||
console.log('🌍 Using BiomeSystem for chunk-based terrain generation');
|
||||
// Biome-based generation will happen via ChunkManager
|
||||
// No need to generate full map here!
|
||||
|
||||
// Create simple grass background as fallback
|
||||
this.createBiomeBackground();
|
||||
} else {
|
||||
console.error('❌ Map2DData not loaded!');
|
||||
this.createFallbackMap();
|
||||
// Fallback to old Map2DData system
|
||||
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!');
|
||||
}
|
||||
|
||||
// 🌍 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() {
|
||||
// 🎨 Create SOLID, OPAQUE tiles (no transparency!)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user