🧹 MINIMAL DemoSceneEnhanced - Tiled Workflow Ready!

COMPLETE REWRITE:
═══════════════════════════════════════════════════════════════
BEFORE: 891 lines with sprite loading, animations, game logic
AFTER:  137 lines with intro text only

REMOVED:
 All sprite loading (Kai, Gronk, Zombies, items, tiles)
 All animations
 All game logic (locket, wheat, quests)
 World creation
 Player movement
 UI systems
 Everything

KEPT:
 Intro text screen (story)
 Empty world (dark grey background)
 "Add content via Tiled" message
 ESC to restart

═══════════════════════════════════════════════════════════════
USER FLOW:
═══════════════════════════════════════════════════════════════
1. Game starts
2. Shows MRTVA DOLINA title + story
3. Press SPACE → Empty world
4. Message: Add content via Tiled Editor
5. Press ESC → Back to intro

Ready for Tiled map integration! 🗺️
This commit is contained in:
2026-01-03 22:14:00 +01:00
parent 4b10a4fa40
commit f2264c668f

View File

@@ -1,822 +1,128 @@
// 🎮 DEMO SCENE ENHANCED - FINAL VERSION WITH REAL SPRITES!
// ✨ Features: Real character sprites, memory system, 4-stage wheat growth
/**
* DemoSceneEnhanced.js
* ═══════════════════════════════════════════════════════════════
* 🎮 MINIMAL TILED MODE - No sprites, just intro text
* ═══════════════════════════════════════════════════════════════
* User will add all content via Tiled Editor
*/
class DemoSceneEnhanced extends Phaser.Scene {
constructor() {
super({ key: 'DemoSceneEnhanced' });
this.player = null;
this.gronk = null;
this.locket = null;
this.wheat = new Map();
this.inventory = {
seeds: 0,
wheat: 0,
gold: 0,
hasLocket: false
};
this.tools = {
hoe: false,
wateringCan: false
};
this.currentTool = null;
this.quest = {
active: false,
target: 5,
planted: 0,
complete: false
};
this.memoria = {
triggered: false
};
}
preload() {
console.log('🎮 DemoSceneEnhanced: Loading REAL assets...');
console.log('🎮 DemoSceneEnhanced: MINIMAL MODE - No sprites, just intro!');
// Items
this.load.image('locket', 'assets/slike 🟢/demo 🔴/items 🔴/item_locket_silver_1767464385940.png');
this.load.image('hoe', 'assets/slike 🟢/demo 🔴/items 🔴/tool_hoe_rusty_1767464400663.png');
this.load.image('bucket', 'assets/slike 🟢/demo 🔴/items 🔴/tool_bucket_old_1767464414881.png');
this.load.image('wateringCan', 'assets/slike 🟢/demo 🔴/items 🔴/tool_watering_can_1767464429022.png');
// ═══════════════════════════════════════════════════════════════
// 🎮 TILED WORKFLOW MODE - NO SPRITE LOADING!
// ═══════════════════════════════════════════════════════════════
// User will add all content via Tiled maps
// This scene just shows intro text and empty world
// Wheat stages (Style 30!)
this.load.image('wheat_stage1', 'assets/slike 🟢/demo 🔴/items 🔴/wheat_s30_stage1_seed_1767464954800.png');
this.load.image('wheat_stage2', 'assets/slike 🟢/demo 🔴/items 🔴/wheat_s30_stage2_sprout_1767464969122.png');
this.load.image('wheat_stage3', 'assets/slike 🟢/demo 🔴/items 🔴/wheat_s30_stage3_growing_1767464984588.png');
this.load.image('wheat_stage4', 'assets/slike 🟢/demo 🔴/items 🔴/wheat_s30_stage4_harvest_1767465000017.png');
// Kai sprites (full walk cycle!)
this.load.image('kai_idle', 'assets/slike 🟢/animations 🟢/kai/kai_idle_down_v2_1767407811684.png');
this.load.image('kai_walk_down_1', 'assets/slike 🟢/animations 🟢/kai/kai_walk_down_01_v2_1767407854249.png');
this.load.image('kai_walk_down_2', 'assets/slike 🟢/animations 🟢/kai/kai_walk_down_02_v2_1767407867687.png');
this.load.image('kai_walk_up_1', 'assets/slike 🟢/animations 🟢/kai/kai_walk_up_01_v2_1767407982776.png');
this.load.image('kai_walk_up_2', 'assets/slike 🟢/animations 🟢/kai/kai_walk_up_02_v2_1767407997148.png');
this.load.image('kai_walk_right_1', 'assets/slike 🟢/animations 🟢/kai/kai_walk_right_01_v2_1767408054275.png');
this.load.image('kai_walk_right_2', 'assets/slike 🟢/animations 🟢/kai/kai_walk_right_02_v2_1767408067872.png');
// Gronk sprites
this.load.image('gronk_idle', 'assets/slike 🟢/animations 🟢/gronk/gronk_idle_down_1767408310253.png');
this.load.image('gronk_vape_1', 'assets/slike 🟢/animations 🟢/gronk/gronk_vape_01_1767408553955.png');
this.load.image('gronk_vape_2', 'assets/slike 🟢/animations 🟢/gronk/gronk_vape_02_1767408567935.png');
// Zombie sprite
this.load.image('zombie_idle', 'assets/slike 🟢/animations 🟢/zombies/base/zombie_basic_idle_1_1767359653518.png');
// World tiles (Style 30!)
this.load.image('grass_tile', 'assets/slike 🟢/demo 🔴/tiles/grass_tile.png');
this.load.image('dirt_tile', 'assets/slike 🟢/demo 🔴/tiles/dirt_tile.png');
this.load.image('tent', 'assets/slike 🟢/demo 🔴/biomi 🔴/buildings/tent.png');
console.log('✅ All assets loaded!');
console.log('✅ No assets to load - Tiled mode!');
}
create() {
console.log('🎮 DemoSceneEnhanced: Starting with REAL sprites!');
console.log('🎮 DemoSceneEnhanced: Creating EMPTY world + Intro text...');
// Setup world
this.cameras.main.setBackgroundColor('#7cfc00');
this.cameras.main.setBounds(0, 0, 2000, 2000);
this.physics.world.setBounds(0, 0, 2000, 2000);
// Setup empty world
this.cameras.main.setBackgroundColor('#2a2a2a'); // Dark grey background
this.cameras.main.setBounds(0, 0, 800, 600);
this.physics.world.setBounds(0, 0, 800, 600);
this.createWorld();
this.createPlayer();
this.createGronk();
this.createZombies();
this.createLocket();
this.setupControls();
this.createUI();
this.showIntroText();
// Create animations
this.createAnimations();
// Camera
this.cameras.main.startFollow(this.player, true, 0.1, 0.1);
this.cameras.main.setZoom(1.5);
this.showInstructions();
console.log('✅ DemoSceneEnhanced: Ready with REAL sprites!');
console.log('✅ Empty world ready - Add content via Tiled!');
}
createAnimations() {
// Kai walk down animation
this.anims.create({
key: 'kai_walk_down',
frames: [
{ key: 'kai_walk_down_1' },
{ key: 'kai_walk_down_2' }
],
frameRate: 8,
repeat: -1
});
showIntroText() {
// ═══════════════════════════════════════════════════════════════
// 📖 INTRO TEXT - Game Story
// ═══════════════════════════════════════════════════════════════
// Kai walk up animation
this.anims.create({
key: 'kai_walk_up',
frames: [
{ key: 'kai_walk_up_1' },
{ key: 'kai_walk_up_2' }
],
frameRate: 8,
repeat: -1
});
const centerX = 400;
const centerY = 300;
// Kai walk right animation
this.anims.create({
key: 'kai_walk_right',
frames: [
{ key: 'kai_walk_right_1' },
{ key: 'kai_walk_right_2' }
],
frameRate: 8,
repeat: -1
});
// Title
this.add.text(centerX, 100, 'MRTVA DOLINA', {
fontSize: '48px',
color: '#ff0000',
fontStyle: 'bold',
stroke: '#000000',
strokeThickness: 4
}).setOrigin(0.5);
// Gronk vaping animation
this.anims.create({
key: 'gronk_vape',
frames: [
{ key: 'gronk_vape_1' },
{ key: 'gronk_vape_2' }
],
frameRate: 4,
repeat: -1
});
// Subtitle
this.add.text(centerX, 160, 'Krvava Žetev', {
fontSize: '32px',
color: '#990000',
fontStyle: 'italic'
}).setOrigin(0.5);
console.log('✅ Animations created!');
}
// Story intro
const storyText = [
'Svet je padel v kaos.',
'Zombiji hodijo med ruševinami.',
'Ti si Kai - preživeli najstnik.',
'',
'Iščeš svojo sestro Ano...',
'',
'Dobrodošel v Mrtvi Dolini.'
].join('\n');
createWorld() {
// Create grass background with REAL tiles (Style 30!)
const tileSize = 64;
const worldWidth = 2000;
const worldHeight = 2000;
// Grass tiles (background)
for (let x = 0; x < worldWidth; x += tileSize) {
for (let y = 0; y < worldHeight; y += tileSize) {
this.add.image(x + tileSize / 2, y + tileSize / 2, 'grass_tile').setDepth(-2);
}
}
// Farm plot with dirt tiles (tilled soil)
for (let x = 3; x < 13; x++) {
for (let y = 3; y < 8; y++) {
this.add.image(x * 64 + 32, y * 64 + 32, 'dirt_tile').setDepth(-1);
}
}
// Tent sprite (REAL Style 30 sprite!)
this.add.image(900, 375, 'tent').setScale(1.2).setDepth(10);
// Add text labels
this.add.text(900, 290, 'TENT', {
fontSize: '24px',
color: '#ffffff',
backgroundColor: '#000000',
padding: { x: 10, y: 5 }
}).setOrigin(0.5).setDepth(100);
this.add.text(500, 200, 'FARM PLOT', {
this.add.text(centerX, centerY, storyText, {
fontSize: '20px',
color: '#ffffff',
backgroundColor: '#000000',
padding: { x: 8, y: 4 }
}).setOrigin(0.5).setDepth(100);
align: 'center',
lineSpacing: 10,
backgroundColor: '#00000088',
padding: { x: 20, y: 20 }
}).setOrigin(0.5);
console.log('✅ World created with Style 30 tiles!');
}
createPlayer() {
const playerX = 500;
const playerY = 500;
// Create player with REAL sprite!
this.player = this.physics.add.sprite(playerX, playerY, 'kai_idle');
this.player.setScale(1.5); // Make bigger so we can see detail
this.player.setCollideWorldBounds(true);
this.player.speed = 200;
this.player.currentDirection = 'down';
console.log('✅ Player (Kai) created with REAL sprite!');
}
createGronk() {
const gronkX = 1200;
const gronkY = 550;
// Create Gronk with REAL sprite!
this.gronk = this.physics.add.sprite(gronkX, gronkY, 'gronk_idle');
this.gronk.setScale(1.5);
// Start vaping animation
this.gronk.play('gronk_vape');
// Add label
const label = this.add.text(gronkX, gronkY - 60, '💨 GRONK 💨', {
// Instructions
this.add.text(centerX, 520, '[Press SPACE or click to start]', {
fontSize: '18px',
color: '#00ff00',
backgroundColor: '#000000',
padding: { x: 8, y: 4 }
});
label.setOrigin(0.5);
this.gronk.label = label;
fontStyle: 'italic'
}).setOrigin(0.5);
console.log('✅ Gronk created with REAL sprite and vaping animation!');
}
createZombies() {
// Add ambient zombies in the background
const zombiePositions = [
{ x: 300, y: 800 },
{ x: 1500, y: 900 },
{ x: 700, y: 1200 }
];
this.zombies = [];
zombiePositions.forEach((pos, index) => {
const zombie = this.physics.add.sprite(pos.x, pos.y, 'zombie_idle');
zombie.setScale(1.3);
zombie.setAlpha(0.7); // Slightly transparent (background)
this.zombies.push(zombie);
// Click to start
this.input.keyboard.once('keydown-SPACE', () => {
this.startGame();
});
console.log('✅ Zombies created with REAL sprites!');
}
createLocket() {
const locketX = 350;
const locketY = 650;
this.locket = this.physics.add.sprite(locketX, locketY, 'locket');
this.locket.setScale(0.8);
// Glowing effect
this.tweens.add({
targets: this.locket,
alpha: { from: 0.5, to: 1 },
scale: { from: 0.75, to: 0.85 },
duration: 1500,
yoyo: true,
repeat: -1
this.input.once('pointerdown', () => {
this.startGame();
});
// Collision detection
this.physics.add.overlap(
this.player,
this.locket,
this.pickupLocket,
null,
this
);
console.log('✅ Locket placed - memory trigger ready!');
}
pickupLocket() {
if (this.inventory.hasLocket) return;
startGame() {
console.log('🎮 Starting game...');
console.log('💎 LOCKET PICKED UP!');
// Clear intro
this.children.removeAll();
this.inventory.hasLocket = true;
this.locket.destroy();
// Show "Add content via Tiled" message
const centerX = 400;
const centerY = 300;
// Trigger memory flashback!
this.triggerMemoryFlashback();
}
triggerMemoryFlashback() {
console.log('💔 MEMORY FLASHBACK TRIGGERED!');
this.memoria.triggered = true;
// Screen flash
this.cameras.main.flash(1000, 255, 255, 255);
// Show memory overlay
const overlay = this.add.rectangle(
this.cameras.main.width / 2,
this.cameras.main.height / 2,
this.cameras.main.width,
this.cameras.main.height,
0x000000,
0.8
);
overlay.setScrollFactor(0);
overlay.setDepth(500);
const memoryText = this.add.text(
this.cameras.main.width / 2,
this.cameras.main.height / 2 - 80,
'💔 MEMORY FLASHBACK 💔',
{
fontSize: '42px',
color: '#ffff00',
fontStyle: 'bold'
}
);
memoryText.setOrigin(0.5);
memoryText.setScrollFactor(0);
memoryText.setDepth(501);
const storyText = this.add.text(
this.cameras.main.width / 2,
this.cameras.main.height / 2,
'Mamin srebrn obesek...\n\nSpomin na dan pred apokalipso.\n\n"Kai, vedno te bom varovala."\n\n- Mama',
{
fontSize: '20px',
color: '#ffffff',
align: 'center',
wordWrap: { width: 600 }
}
);
storyText.setOrigin(0.5);
storyText.setScrollFactor(0);
storyText.setDepth(501);
const closeText = this.add.text(
this.cameras.main.width / 2,
this.cameras.main.height / 2 + 120,
'[Press E to continue]',
{
fontSize: '16px',
color: '#888888'
}
);
closeText.setOrigin(0.5);
closeText.setScrollFactor(0);
closeText.setDepth(501);
// Pulse effect
this.tweens.add({
targets: [memoryText, storyText],
alpha: { from: 0, to: 1 },
duration: 1000
});
// Close on E
const closeHandler = () => {
overlay.destroy();
memoryText.destroy();
storyText.destroy();
closeText.destroy();
this.keys.E.off('down', closeHandler);
console.log('✅ Memory complete - locket added to inventory');
};
this.keys.E.once('down', closeHandler);
}
setupControls() {
this.keys = {
W: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.W),
A: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.A),
S: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.S),
D: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.D),
E: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E),
ONE: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.ONE),
TWO: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.TWO)
};
this.keys.E.on('down', () => this.interact());
this.keys.ONE.on('down', () => this.selectTool('hoe'));
this.keys.TWO.on('down', () => this.selectTool('seeds'));
}
createUI() {
this.inventoryText = this.add.text(10, 10, '', {
fontSize: '16px',
this.add.text(centerX, centerY, 'Empty World\n\nAdd content via Tiled Editor\n\n(Press ESC to see intro again)', {
fontSize: '24px',
color: '#ffffff',
backgroundColor: '#000000',
padding: { x: 10, y: 5 }
align: 'center',
lineSpacing: 15,
backgroundColor: '#00000088',
padding: { x: 30, y: 30 }
}).setOrigin(0.5);
// ESC to go back to intro
this.input.keyboard.on('keydown-ESC', () => {
this.scene.restart();
});
this.inventoryText.setScrollFactor(0);
this.inventoryText.setDepth(100);
this.questText = this.add.text(this.cameras.main.width - 10, 10, '', {
fontSize: '16px',
color: '#ffff00',
backgroundColor: '#000000',
padding: { x: 10, y: 5 }
});
this.questText.setOrigin(1, 0);
this.questText.setScrollFactor(0);
this.questText.setDepth(100);
this.toolText = this.add.text(10, 50, '', {
fontSize: '14px',
color: '#00ff00',
backgroundColor: '#000000',
padding: { x: 8, y: 3 }
});
this.toolText.setScrollFactor(0);
this.toolText.setDepth(100);
this.updateUI();
}
showInstructions() {
const instructions = this.add.text(
this.cameras.main.width / 2,
this.cameras.main.height - 50,
'WASD: Move | E: Talk/Interact | 1: Hoe | 2: Plant Seeds | Click: Use Tool',
{
fontSize: '16px',
color: '#ffffff',
backgroundColor: '#000000',
padding: { x: 15, y: 8 }
}
);
instructions.setOrigin(0.5);
instructions.setScrollFactor(0);
instructions.setDepth(100);
// Fade out after 15 seconds
this.time.delayedCall(15000, () => {
this.tweens.add({
targets: instructions,
alpha: 0,
duration: 2000,
onComplete: () => instructions.destroy()
});
});
}
interact() {
// Check Gronk
const distToGronk = Phaser.Math.Distance.Between(
this.player.x, this.player.y,
this.gronk.x, this.gronk.y
);
if (distToGronk < 100) {
this.talkToGronk();
return;
}
// Check wheat harvest
const tileX = Math.floor(this.player.x / 64);
const tileY = Math.floor(this.player.y / 64);
const key = `${tileX},${tileY}`;
if (this.wheat.has(key)) {
const crop = this.wheat.get(key);
if (crop.stage === 4) {
this.harvestWheat(tileX, tileY);
}
}
}
talkToGronk() {
console.log('💬 Talking to Gronk...');
if (!this.quest.active) {
this.showDialogue(
'💨 GRONK',
'*vapes*\n\nYo! Want to learn farming?\nPlant 5 wheat and I\'ll hook you up with gold!',
() => {
this.quest.active = true;
this.inventory.seeds = 5;
this.tools.hoe = true;
this.tools.wateringCan = true;
this.updateUI();
console.log('✅ Quest started!');
}
);
} else if (this.quest.complete) {
this.showDialogue(
'💨 GRONK',
'*vapes*\n\nYo that\'s fire! 🔥\n\nHere\'s 100 gold. You\'re a natural!\n\nDEMO COMPLETE!',
() => {
this.inventory.gold += 100;
this.updateUI();
this.showDemoComplete();
}
);
} else {
this.showDialogue(
'💨 GRONK',
`*vapes*\n\nKeep going! ${this.quest.planted}/5 wheat planted.`
);
}
}
showDialogue(name, text, onClose) {
const box = this.add.rectangle(
this.cameras.main.width / 2,
this.cameras.main.height - 100,
700, 140,
0x000000, 0.9
);
box.setScrollFactor(0);
box.setDepth(200);
const nameText = this.add.text(
this.cameras.main.width / 2,
this.cameras.main.height - 150,
name,
{
fontSize: '22px',
color: '#00ff00',
fontStyle: 'bold'
}
);
nameText.setOrigin(0.5);
nameText.setScrollFactor(0);
nameText.setDepth(201);
const dialogueText = this.add.text(
this.cameras.main.width / 2,
this.cameras.main.height - 100,
text,
{
fontSize: '18px',
color: '#ffffff',
align: 'center',
wordWrap: { width: 650 }
}
);
dialogueText.setOrigin(0.5);
dialogueText.setScrollFactor(0);
dialogueText.setDepth(201);
const closeText = this.add.text(
this.cameras.main.width / 2,
this.cameras.main.height - 40,
'[Press E to close]',
{
fontSize: '14px',
color: '#888888'
}
);
closeText.setOrigin(0.5);
closeText.setScrollFactor(0);
closeText.setDepth(201);
const closeHandler = () => {
box.destroy();
nameText.destroy();
dialogueText.destroy();
closeText.destroy();
this.keys.E.off('down', closeHandler);
if (onClose) onClose();
};
this.keys.E.once('down', closeHandler);
}
selectTool(tool) {
if (this.tools[tool]) {
this.currentTool = tool;
this.updateUI();
console.log('🔧 Selected:', tool);
}
}
useTool() {
if (!this.currentTool) return;
const tileX = Math.floor(this.player.x / 64);
const tileY = Math.floor(this.player.y / 64);
const key = `${tileX},${tileY}`;
if (this.currentTool === 'seeds') {
if (this.inventory.seeds > 0 && !this.wheat.has(key)) {
this.plantWheat(tileX, tileY);
}
}
}
plantWheat(tileX, tileY) {
this.inventory.seeds--;
this.quest.planted++;
const x = tileX * 64 + 32;
const y = tileY * 64 + 32;
// Create wheat sprite at stage 1
const sprite = this.add.sprite(x, y, 'wheat_stage1');
sprite.setScale(1.2);
const crop = {
stage: 1,
sprite: sprite,
planted: Date.now(),
growTimer: null
};
this.wheat.set(key, crop);
// Auto-grow stages every 10 seconds
crop.growTimer = this.time.addEvent({
delay: 10000,
callback: () => this.growWheat(key),
repeat: 3
});
if (this.quest.planted >= this.quest.target) {
this.quest.complete = true;
}
this.updateUI();
console.log(`🌱 Planted wheat at ${tileX},${tileY}`);
}
growWheat(key) {
if (!this.wheat.has(key)) return;
const crop = this.wheat.get(key);
if (crop.stage >= 4) return;
crop.stage++;
crop.sprite.setTexture(`wheat_stage${crop.stage}`);
// Scale up as it grows
crop.sprite.setScale(1.0 + (crop.stage * 0.15));
console.log(`🌾 Wheat grew to stage ${crop.stage}`);
if (crop.stage === 4) {
// Add sparkle effect for ready harvest
this.tweens.add({
targets: crop.sprite,
alpha: { from: 0.8, to: 1 },
duration: 800,
yoyo: true,
repeat: -1
});
}
}
harvestWheat(tileX, tileY) {
const key = `${tileX},${tileY}`;
const crop = this.wheat.get(key);
if (crop) {
crop.sprite.destroy();
if (crop.growTimer) crop.growTimer.destroy();
this.wheat.delete(key);
this.inventory.wheat++;
this.inventory.seeds++; // Get seeds back
this.updateUI();
console.log('✅ Harvested wheat!');
}
}
showDemoComplete() {
const bg = this.add.rectangle(
this.cameras.main.width / 2,
this.cameras.main.height / 2,
this.cameras.main.width,
this.cameras.main.height,
0x000000, 0.85
);
bg.setScrollFactor(0);
bg.setDepth(300);
const title = this.add.text(
this.cameras.main.width / 2,
this.cameras.main.height / 2 - 120,
'🎉 DEMO COMPLETE! 🎉',
{
fontSize: '52px',
color: '#ffff00',
fontStyle: 'bold'
}
);
title.setOrigin(0.5);
title.setScrollFactor(0);
title.setDepth(301);
const stats = this.add.text(
this.cameras.main.width / 2,
this.cameras.main.height / 2 - 20,
`Wheat Planted: ${this.quest.planted}\nWheat Harvested: ${this.inventory.wheat}\nGold Earned: ${this.inventory.gold}g\n\n💎 Locket Found: ${this.inventory.hasLocket ? 'YES' : 'NO'}`,
{
fontSize: '22px',
color: '#ffffff',
align: 'center'
}
);
stats.setOrigin(0.5);
stats.setScrollFactor(0);
stats.setDepth(301);
const footer = this.add.text(
this.cameras.main.width / 2,
this.cameras.main.height / 2 + 100,
'Thank you for playing!\nFull game coming soon on Kickstarter!',
{
fontSize: '20px',
color: '#00ff00',
align: 'center'
}
);
footer.setOrigin(0.5);
footer.setScrollFactor(0);
footer.setDepth(301);
// Pulse animation
this.tweens.add({
targets: title,
scale: { from: 1, to: 1.1 },
duration: 1000,
yoyo: true,
repeat: -1
});
console.log('🎉 DEMO COMPLETE!');
}
updateUI() {
// Inventory
let invText = `Seeds: ${this.inventory.seeds} | Wheat: ${this.inventory.wheat} | Gold: ${this.inventory.gold}g`;
if (this.inventory.hasLocket) {
invText += ' | 💎 Locket';
}
this.inventoryText.setText(invText);
// Quest
if (this.quest.active) {
this.questText.setText(
`Quest: Plant Wheat ${this.quest.planted}/${this.quest.target}` +
(this.quest.complete ? ' - COMPLETE!' : '')
);
}
// Tool
if (this.currentTool) {
this.toolText.setText(`Tool: ${this.currentTool.toUpperCase()}`);
} else {
this.toolText.setText('');
}
}
update() {
if (!this.player) return;
// Movement with animations!
let velocityX = 0;
let velocityY = 0;
let moving = false;
if (this.keys.W.isDown) {
velocityY = -1;
moving = true;
if (this.player.anims.currentAnim?.key !== 'kai_walk_up') {
this.player.play('kai_walk_up');
}
} else if (this.keys.S.isDown) {
velocityY = 1;
moving = true;
if (this.player.anims.currentAnim?.key !== 'kai_walk_down') {
this.player.play('kai_walk_down');
}
}
if (this.keys.A.isDown) {
velocityX = -1;
moving = true;
this.player.setFlipX(true);
if (this.player.anims.currentAnim?.key !== 'kai_walk_right') {
this.player.play('kai_walk_right');
}
} else if (this.keys.D.isDown) {
velocityX = 1;
moving = true;
this.player.setFlipX(false);
if (this.player.anims.currentAnim?.key !== 'kai_walk_right') {
this.player.play('kai_walk_right');
}
}
// Stop animation when not moving
if (!moving) {
this.player.stop();
this.player.setTexture('kai_idle');
}
// Normalize diagonal
if (velocityX !== 0 && velocityY !== 0) {
velocityX *= 0.707;
velocityY *= 0.707;
}
this.player.setVelocity(
velocityX * this.player.speed,
velocityY * this.player.speed
);
// Use tool with click
if (this.input.activePointer.isDown && this.currentTool) {
this.useTool();
}
// Update Gronk label
if (this.gronk && this.gronk.label) {
this.gronk.label.setPosition(this.gronk.x, this.gronk.y - 60);
}
// Empty - no game loop needed for intro screen
}
}