shrani
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// NovaFarma v2 - Fresh Start
|
||||
// Minimal Phaser config
|
||||
|
||||
const config = {
|
||||
type: Phaser.CANVAS,
|
||||
width: 1280,
|
||||
height: 720,
|
||||
backgroundColor: '#44aa44', // Grass green - hides gaps!
|
||||
scene: [PreloadScene, GameScene],
|
||||
physics: {
|
||||
default: 'arcade',
|
||||
arcade: {
|
||||
gravity: { y: 0 },
|
||||
debug: false
|
||||
}
|
||||
},
|
||||
scale: {
|
||||
mode: Phaser.Scale.FIT,
|
||||
autoCenter: Phaser.Scale.CENTER_BOTH
|
||||
}
|
||||
};
|
||||
|
||||
const game = new Phaser.Game(config);
|
||||
|
||||
console.log('🎮 NovaFarma v2 - Fresh Start!');
|
||||
@@ -0,0 +1,59 @@
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// PreloadScene - Load 2.5D tiles ONLY
|
||||
class PreloadScene extends Phaser.Scene {
|
||||
constructor() {
|
||||
super({ key: 'PreloadScene' });
|
||||
}
|
||||
|
||||
preload() {
|
||||
console.log('⏳ Loading 2.5D tiles...');
|
||||
|
||||
// Force fresh load with timestamp
|
||||
const t = Date.now();
|
||||
this.load.image('grass_tile', `assets/grass_tile.png?v=${t}`);
|
||||
this.load.image('water_tile', `assets/water_tile.png?v=${t}`);
|
||||
|
||||
console.log('✅ Tiles loaded!');
|
||||
}
|
||||
|
||||
create() {
|
||||
console.log('🎬 Starting GameScene...');
|
||||
this.scene.start('GameScene');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user