Odstranil reko in generirano zemljo (reset mape)

This commit is contained in:
2026-01-31 10:49:33 +01:00
parent b2667d483c
commit 01abf6e3a4

View File

@@ -112,115 +112,17 @@ export default class GrassSceneClean extends Phaser.Scene {
const BG_W = this.scale.width * 2.5;
const BG_H = this.scale.height * 2.5;
// 2. GENERIRANJE SEAMLESS TEKSTURE
// Ustvarimo gosto teksturo zemlje, da ni lukenj
const texSize = 512;
const rt = this.make.renderTexture({ width: texSize, height: texSize }, false);
// Zapolnimo s temno barvo
rt.fill(0x4e342e);
// Narišemo veliko "ground_base" slikic, da prekrijemo vse
const patchCount = 50;
for (let i = 0; i < patchCount; i++) {
let x = Math.random() * texSize;
let y = Math.random() * texSize;
let angle = Math.random() * 360;
let scale = 0.8 + Math.random() * 0.5;
rt.draw('ground_base', x, y, 1, 0xffffff);
// Dodatno risanje na robovih za seamless efekt (wrapping)
// (Poenostavljeno: samo gosto napolnimo)
}
// Shranimo teksturo pod novim ključem
rt.saveTexture('ground_seamless_gen');
// 3. Uporabimo novo generirano teksturo
this.ground = this.add.tileSprite(this.scale.width / 2, this.scale.height / 2, BG_W, BG_H, 'ground_seamless_gen');
// 2. Uporabimo originalno sliko za tileSprite (Clean Slate)
this.ground = this.add.tileSprite(this.scale.width / 2, this.scale.height / 2, BG_W, BG_H, 'ground_base');
this.ground.setScrollFactor(0); // Sticks to camera
this.ground.setDepth(-100);
// Note: We need to update tilePosition in update() loop to match camera scroll!
// --- 2. RIVER SYSTEM (Infinite Scrolling) ---
// Ustvarimo neskončno reko čez celo mapo (HORIZONTALNO)
const riverY = WORLD_H / 2 + 300; // Spodaj od centra (ali kjerkoli želiš)
// Najprej dobimo teksturo, da preverimo dimenzije
const riverTex = this.textures.get('river_tile_seamless').getSourceImage();
const riverHeight = riverTex.height; // Višina originalne slike
// Uporabimo tileSprite, ki sega od leve do desne strani sveta
// Širina = WORLD_W (32000px), Višina = originalna višina slike
this.river = this.add.tileSprite(WORLD_W / 2, riverY, WORLD_W, riverHeight, 'river_tile_seamless');
this.river.setDepth(-50); // Nad zemljo (-100), pod igralcem (Y)
// ROTACIJA TEKSTURE: Ker je originalna slika verjetno navpična (tok dol), jo moramo ali rotirati
// ali pa predpostaviti, da je že vodoravna.
// Če je slika "tok navzdol", in jo raztegnemo vodoravno, bo izgledalo čudno.
// Ampak tileSprite ne podpira rotacije teksture znotraj (samo cel objekt).
// Zato bomo zarotirali cel tileSprite za 90 stopinj!
this.river.setAngle(90);
// Ko zarotiramo za 90, se Width in Height zamenjata v vizualnem smislu.
// Zato moramo nastaviti dimenzije obratno:
// Width (ki postane višina) = WORLD_W
// Height (ki postane širina) = riverHeight
// Vendar tileSprite logika deluje na lokalnih oseh.
// POPRAVEK: Namesto rotacije (ki zaplete tilePosition), raje nastavimo:
// Width = riverHeight (ožja stranica)
// Height = WORLD_W (dolga stranica)
// In nato zarotiramo za -90 stopinj, da leži vodoravno.
this.river.setSize(riverHeight, WORLD_W);
this.river.setAngle(-90);
// FIZIKA: Reka je ovira (ne moreš čeznjo)
this.physics.add.existing(this.river, true); // Static body
// Zaradi rotacije moramo ročno nastaviti physics body (ker body se ne rotira avtomatsko z objektom na isti način)
// Body je AABB (Axis Aligned Bounding Box).
// Želimo vodoraven body: Širina = WORLD_W, Višina = riverHeight * 0.6 (ožja struga)
this.river.body.setSize(WORLD_W, riverHeight * 0.6);
// Center body-a se mora ujemati s centrom reke
// Offset je relativen na top-left texture (ki je zarotirana). To je zapleteno.
// Najlažje: Body nastavimo na novo, neodvisno od sprite-a.
// Rešitev za fiziko: Ustvarimo nevidno cono za kolizijo, ker rotiran tileSprite dela težave z body-em
this.riverCollider = this.add.rectangle(WORLD_W / 2, riverY, WORLD_W, riverHeight * 0.6, 0x0000ff, 0);
this.physics.add.existing(this.riverCollider, true);
// Vizualni trik
this.river.setTint(0xdddddd);
// --- 2.1 BREG REKE (River Banks - Dirt) ---
// Dodamo zemljo ob robove reke
const bankThickness = 64; // Debelina brega
const steps = Math.ceil(WORLD_W / 128); // Koliko kosov zemlje rabimo
// Zgornji in spodnji breg (glede na reko, ki je sedaj vodoravna)
// Ker je reka na riverY, sta bregova na riverY +/- (riverHeight/2 + offset)
const bankTopY = riverY - (riverHeight / 2) - 20;
const bankBottomY = riverY + (riverHeight / 2) + 20;
for (let i = 0; i < steps; i++) {
let bx = (i * 128); // Začnemo od 0 do WORLD_W
// Zgornji breg
let d1 = this.add.image(bx, bankTopY, 'ground_base');
d1.setDepth(-49); // Tik nad reko, pod igralcem
d1.setAngle(Math.random() * 360);
d1.setScale(0.8 + Math.random() * 0.4);
d1.setTint(0xcccccc); // Malo temnejša zemlja
// Spodnji breg
let d2 = this.add.image(bx, bankBottomY, 'ground_base');
d2.setDepth(-49);
d2.setAngle(Math.random() * 360);
d2.setScale(0.8 + Math.random() * 0.4);
d2.setTint(0xcccccc);
}
// --- 2. RIVER SYSTEM (Removed) ---
/*
// Removed per user request ("odstrani vse")
*/
// --- 2.1 Prejšnji Stream System (Removed) ---
/*
@@ -719,7 +621,7 @@ export default class GrassSceneClean extends Phaser.Scene {
// 3. COLLIDERS
if (this.stream) this.physics.add.collider(this.kai, this.stream);
this.physics.add.collider(this.kai, this.riverCollider); // Nova reka (nevidna kolizija)
// this.physics.add.collider(this.kai, this.riverCollider); // Removed
// this.physics.add.collider(this.kai, this.obstaclesGroup);
// --- ANIMATIONS ---
@@ -877,13 +779,12 @@ export default class GrassSceneClean extends Phaser.Scene {
this.ground.tilePositionY = this.cameras.main.scrollY;
}
// 2. River Flow Animation
// Premikamo tilePositionY, da voda "teče" navzdol
// Ker smo zarotirali tileSprite za -90 stopinj, "navzdol" po lokalni osi Y pomeni "levo" v globalnem prostoru.
// Če želimo tok levo-desno, moramo premikati Y os teksture (ki je sedaj vodoravna).
// 2. River Flow Animation (Removed)
/*
if (this.river) {
this.river.tilePositionY -= 2.0;
}
*/
// --- PLAYER MOVEMENT ---
const speed = 250;