Implement randomized tile textures.
- DungeonGenerator: Selects a random texture from the card definition when finalizing tile placement. - GameRenderer: Renders the specific chosen texture for each tile instance instead of the default.
This commit is contained in:
@@ -261,11 +261,20 @@ export class DungeonGenerator {
|
||||
placeCardFinal(card, x, y, rotation) {
|
||||
const variant = card.variants[rotation];
|
||||
|
||||
// Randomize Texture if multiple are available
|
||||
let selectedTexture = null;
|
||||
if (card.textures && card.textures.length > 0) {
|
||||
const idx = Math.floor(Math.random() * card.textures.length);
|
||||
selectedTexture = card.textures[idx];
|
||||
console.log(`[DungeonGenerator] Selected texture for ${card.id}:`, selectedTexture);
|
||||
}
|
||||
|
||||
const instance = {
|
||||
id: `tile_${this.placedTiles.length}`,
|
||||
defId: card.id,
|
||||
x, y, rotation,
|
||||
name: card.name
|
||||
name: card.name,
|
||||
texture: selectedTexture
|
||||
};
|
||||
|
||||
this.grid.placeTile(instance, variant, card);
|
||||
|
||||
@@ -498,7 +498,8 @@ export class GameRenderer {
|
||||
// Draw Texture Plane (The Image) - WAIT FOR TEXTURE TO LOAD
|
||||
if (tileDef && tileInstance && tileDef.textures && tileDef.textures.length > 0) {
|
||||
|
||||
const texturePath = tileDef.textures[0];
|
||||
// Use specific texture if assigned (randomized), otherwise default to first
|
||||
const texturePath = tileInstance.texture || tileDef.textures[0];
|
||||
|
||||
// Load texture with callback
|
||||
this.getTexture(texturePath, (texture) => {
|
||||
|
||||
Reference in New Issue
Block a user