This commit is contained in:
2025-12-12 02:41:00 +01:00
parent e15b429e75
commit 84b07bb433
13 changed files with 1917 additions and 76 deletions

View File

@@ -16,7 +16,7 @@ const ABANDONED_HOUSES = [
// ========================================================
// GOZD KONSTANTE - STARDEW VALLEY STYLE (OPTIMIZIRANO)
// ========================================================
const TREE_DENSITY = 0.01; // 1% chance za drevo (zelo nizka gostota)
const TREE_DENSITY = 0.0; // 0% - BREZ DREVES!
const PURPLE_TREE_CHANCE = 0.30; // 30% vijolčnih dreves
const FRUIT_TREE_CHANCE = 0.20; // 20% sadnih dreves
const ROCK_DENSITY_THRESHOLD = 0.60; // Prag za skupine skal
@@ -29,6 +29,13 @@ const TILE_MINE_WALL = 81; // ID za zid rudnika
const TILE_STONE_ORE = 82; // ID za navadni kamen
const TILE_IRON_ORE = 83; // ID za železovo rudo
// ========================================================
// RIBNIK KONSTANTE
// ========================================================
const POND_CENTER_X = 30; // Center ribnika
const POND_CENTER_Y = 30; // Center ribnika
const POND_RADIUS = 4; // Radij ribnika (8x8)
// Terrain Generator System
class TerrainSystem {
constructor(scene, width = 100, height = 100) {
@@ -53,6 +60,10 @@ class TerrainSystem {
this.waterTiles = []; // Array za water tiles
this.waterAnimationTimer = 0;
// Rain particles za ribnik
this.rainEmitter = null;
this.splashEmitters = []; // Array splash emitterjev
this.tilePool = {
active: [],
inactive: [],
@@ -168,6 +179,32 @@ class TerrainSystem {
const types = Object.values(this.terrainTypes);
// POSEBNA OBDELAVA ZA VODO - 2D Stardew Valley Style!
if (!this.scene.textures.exists('water')) {
const waterGraphics = this.scene.make.graphics({ x: 0, y: 0, add: false });
// TEMNA MODRA VODA - dobro vidna!
waterGraphics.fillGradientStyle(
0x0a3d62, 0x0a3d62, // Temno modra (zgoraj)
0x1e5f8c, 0x1e5f8c // Srednje modra (spodaj)
);
waterGraphics.fillRect(0, 0, 48, 48);
// Svetli highlights za valovanje
waterGraphics.fillStyle(0x3a8fc2, 0.5);
waterGraphics.fillCircle(12, 12, 10);
waterGraphics.fillCircle(36, 28, 8);
waterGraphics.fillCircle(24, 38, 6);
// Temnejši border za kontrast
waterGraphics.lineStyle(2, 0x062a40, 1);
waterGraphics.strokeRect(0, 0, 48, 48);
waterGraphics.generateTexture('water', 48, 48);
waterGraphics.destroy();
console.log('🌊 2D Water texture created (Stardew Valley style)!');
}
types.forEach((type) => {
if (this.scene.textures.exists(type.name)) return;
@@ -355,6 +392,7 @@ class TerrainSystem {
generate() {
this.createTileTextures();
this.createWaterFrames(); // Ustvari water animation frames!
console.log('🌍 Initializing World (Zone Streaming Mode)...');
@@ -421,6 +459,15 @@ class TerrainSystem {
}
});
// RIBNIK - okrogel ribnik z vodo!
const distToPond = Math.sqrt(
Math.pow(x - POND_CENTER_X, 2) +
Math.pow(y - POND_CENTER_Y, 2)
);
if (distToPond <= POND_RADIUS) {
terrainType = this.terrainTypes.WATER; // Voda!
}
// Create Tile Data
this.tiles[y][x] = {
type: terrainType.name,
@@ -563,8 +610,45 @@ class TerrainSystem {
init(offsetX, offsetY) {
this.offsetX = offsetX;
this.offsetY = offsetY;
// Ustvari rain particles nad ribnikom
this.createRainOnPond();
}
createRainOnPond() {
// Izračunaj screen pozicijo ribnika
const pondScreenPos = this.iso.toScreen(POND_CENTER_X, POND_CENTER_Y);
const pondX = pondScreenPos.x + this.offsetX;
const pondY = pondScreenPos.y + this.offsetY;
// Ustvari particle texture (modra kapljica)
const graphics = this.scene.make.graphics({ x: 0, y: 0, add: false });
graphics.fillStyle(0x4488ff, 1);
graphics.fillCircle(2, 2, 2);
graphics.generateTexture('raindrop', 4, 4);
graphics.destroy();
// Rain emitter - pada v ribnik
this.rainEmitter = this.scene.add.particles(pondX, pondY - 100, 'raindrop', {
x: { min: -50, max: 50 },
y: 0,
lifespan: 1000,
speedY: { min: 200, max: 300 },
scale: { start: 0.5, end: 0.2 },
alpha: { start: 0.8, end: 0.3 },
frequency: 100,
blendMode: 'ADD'
});
// Dodaj rain sound effect
if (this.scene.soundManager) {
this.scene.soundManager.playRainSound();
}
console.log('🌧️ Rain particles created over pond!');
}
setTile(x, y, type) {
if (x >= 0 && x < this.width && y >= 0 && y < this.height) {
this.tiles[y][x].type = type;
@@ -887,15 +971,17 @@ class TerrainSystem {
// Use water texture with animation support
if (tile.type === 'water') {
// Check if water frames exist
if (this.scene.textures.exists('water_frame_0')) {
sprite.setTexture('water_frame_0');
// Mark sprite for animation
sprite.isWater = true;
sprite.waterFrame = 0;
} else {
sprite.setTexture('water');
}
sprite.setTexture('water');
// ANIMACIJA: Dodaj alpha tween za valovanje
this.scene.tweens.add({
targets: sprite,
alpha: 0.7,
duration: 1000,
yoyo: true,
repeat: -1,
ease: 'Sine.easeInOut'
});
} else {
sprite.setTexture(tile.type);
}
@@ -1086,43 +1172,9 @@ class TerrainSystem {
return true; // Out of bounds = solid
}
// Water Animation Update
// Water Animation Update - DISABLED (using tweens now)
update(time, delta) {
// Posodobi water animation timer
this.waterAnimationTimer += delta;
// Water frame animacija (vsake 150ms = ~6.6 FPS za smooth flow)
if (this.waterAnimationTimer > 150) {
this.waterAnimationTimer = 0;
// Increment frame counter
if (!this.waterCurrentFrame) this.waterCurrentFrame = 0;
this.waterCurrentFrame = (this.waterCurrentFrame + 1) % 4; // Cycle 0-3
// DEBUG
let waterTileCount = 0;
// Update vse visible water tiles s novim frame-om
this.visibleTiles.forEach((sprite, key) => {
const coords = key.split(',');
const x = parseInt(coords[0]);
const y = parseInt(coords[1]);
if (this.tiles[y] && this.tiles[y][x] && this.tiles[y][x].type === 'water') {
sprite.setTexture(`water_frame_${this.waterCurrentFrame}`);
waterTileCount++;
}
});
// DEBUG LOG
if (waterTileCount > 0) {
console.log(`🌊 Water animation: frame ${this.waterCurrentFrame} updated ${waterTileCount} tiles`);
} else {
console.warn('⚠️ No water tiles found in visibleTiles!', {
visibleTilesCount: this.visibleTiles.size,
currentFrame: this.waterCurrentFrame
});
}
}
// Water animation je zdaj implementirana z Phaser tweens
// Ni potrebe po ročnem frame update-u
}
}