Files
novafarma/backup_faza11_extracted/backup_faza11_2025-12-11/src/scenes/GameScene.js
2025-12-11 11:34:23 +01:00

60 lines
2.0 KiB
JavaScript

// GameScene - Render 2.5D tiles in simple grid
class GameScene extends Phaser.Scene {
constructor() {
super({ key: 'GameScene' });
}
create() {
console.log('🎮 GameScene started!');
// Tile size - VERY BIG overlap for seamless Minecraft blocks!
const tileSize = 64;
const tileDisplay = 80; // HUGE overlap = perfect platform!
const mapWidth = 500; // HUGE MAP! 🗺️
const mapHeight = 500; // HUGE MAP! 🗺️
console.log('🌍 Generating 500x500 Minecraft world...');
// Render simple tile grid
for (let y = 0; y < mapHeight; y++) {
for (let x = 0; x < mapWidth; x++) {
// Determine tile type (simple - grass everywhere, water on edges)
let tileKey = 'grass_tile';
// Water on edges
if (x === 0 || x === mapWidth - 1 || y === 0 || y === mapHeight - 1) {
tileKey = 'water_tile';
}
// Create tile sprite
const tile = this.add.image(
x * tileSize + tileSize / 2,
y * tileSize + tileSize / 2,
tileKey
);
// Scale larger to eliminate gaps
tile.setDisplaySize(tileDisplay, tileDisplay);
}
}
// Camera
this.cameras.main.setBounds(0, 0, mapWidth * tileSize, mapHeight * tileSize);
this.cameras.main.setZoom(1.0);
console.log('✅ Tiles rendered! Map size:', mapWidth, 'x', mapHeight);
console.log('🌸 You should see grass tiles with flowers!');
}
update() {
// Camera controls
const cam = this.cameras.main;
const speed = 5;
if (this.input.keyboard.addKey('W').isDown) cam.scrollY -= speed;
if (this.input.keyboard.addKey('S').isDown) cam.scrollY += speed;
if (this.input.keyboard.addKey('A').isDown) cam.scrollX -= speed;
if (this.input.keyboard.addKey('D').isDown) cam.scrollX += speed;
}
}