This commit is contained in:
2025-12-08 10:47:53 +01:00
parent 5de27d0b04
commit b79b70dcc1
11 changed files with 1001 additions and 21 deletions

View File

@@ -648,6 +648,323 @@ class TextureGenerator {
TextureGenerator.createGravestoneSprite(this.scene);
TextureGenerator.createToolSprites(this.scene);
TextureGenerator.createItemSprites(this.scene);
TextureGenerator.createScooterSprite(this.scene, 'scooter', false);
TextureGenerator.createScooterSprite(this.scene, 'scooter_broken', true);
TextureGenerator.createAnimatedWaterSprite(this.scene);
TextureGenerator.createPathStoneSprite(this.scene, 'path_stone');
TextureGenerator.createSmallRockSprite(this.scene, 'small_rock_1');
TextureGenerator.createSmallRockSprite(this.scene, 'small_rock_2');
TextureGenerator.createFlowerVariant(this.scene, 'flower_red', '#FF4444');
TextureGenerator.createFlowerVariant(this.scene, 'flower_yellow', '#FFFF44');
TextureGenerator.createFlowerVariant(this.scene, 'flower_blue', '#4444FF');
TextureGenerator.createMushroomSprite(this.scene, 'mushroom_red', '#FF4444', '#FFFFFF');
TextureGenerator.createMushroomSprite(this.scene, 'mushroom_brown', '#8B4513', '#FFE4C4');
TextureGenerator.createFallenLogSprite(this.scene, 'fallen_log');
TextureGenerator.createPuddleSprite(this.scene, 'puddle');
}
static createPathStoneSprite(scene, key = 'path_stone') {
if (scene.textures.exists(key)) return;
const canvas = scene.textures.createCanvas(key, 32, 32);
const ctx = canvas.getContext();
ctx.clearRect(0, 0, 32, 32);
// Flat stone for paths
ctx.fillStyle = '#888888';
ctx.beginPath();
ctx.ellipse(16, 20, 12, 8, 0, 0, Math.PI * 2);
ctx.fill();
// Cracks/Details
ctx.strokeStyle = '#666666';
ctx.lineWidth = 1;
ctx.beginPath();
ctx.moveTo(10, 18);
ctx.lineTo(22, 18);
ctx.stroke();
canvas.refresh();
}
static createSmallRockSprite(scene, key) {
if (scene.textures.exists(key)) return;
const canvas = scene.textures.createCanvas(key, 24, 24);
const ctx = canvas.getContext();
ctx.clearRect(0, 0, 24, 24);
// Small rock pile
ctx.fillStyle = '#707070';
ctx.beginPath();
ctx.arc(12, 16, 6, 0, Math.PI * 2);
ctx.fill();
// Highlight
ctx.fillStyle = '#909090';
ctx.beginPath();
ctx.arc(10, 14, 3, 0, Math.PI * 2);
ctx.fill();
canvas.refresh();
}
static createFlowerVariant(scene, key, color) {
if (scene.textures.exists(key)) return;
const canvas = scene.textures.createCanvas(key, 32, 32);
const ctx = canvas.getContext();
ctx.clearRect(0, 0, 32, 32);
// Stem
ctx.fillStyle = '#228B22';
ctx.fillRect(15, 16, 2, 10);
// Petals
ctx.fillStyle = color;
for (let i = 0; i < 5; i++) {
const angle = (i / 5) * Math.PI * 2;
const px = 16 + Math.cos(angle) * 4;
const py = 16 + Math.sin(angle) * 4;
ctx.beginPath();
ctx.arc(px, py, 3, 0, Math.PI * 2);
ctx.fill();
}
// Center
ctx.fillStyle = '#FFD700';
ctx.beginPath();
ctx.arc(16, 16, 2, 0, Math.PI * 2);
ctx.fill();
canvas.refresh();
}
static createMushroomSprite(scene, key, capColor, stemColor) {
if (scene.textures.exists(key)) return;
const canvas = scene.textures.createCanvas(key, 32, 32);
const ctx = canvas.getContext();
ctx.clearRect(0, 0, 32, 32);
// Stem
ctx.fillStyle = stemColor;
ctx.fillRect(13, 16, 6, 10);
// Cap (mushroom head)
ctx.fillStyle = capColor;
ctx.beginPath();
ctx.ellipse(16, 16, 10, 6, 0, 0, Math.PI * 2);
ctx.fill();
// Spots on cap (white dots)
ctx.fillStyle = '#FFFFFF';
for (let i = 0; i < 3; i++) {
const angle = (i / 3) * Math.PI * 2;
const px = 16 + Math.cos(angle) * 5;
const py = 16 + Math.sin(angle) * 3;
ctx.beginPath();
ctx.arc(px, py, 2, 0, Math.PI * 2);
ctx.fill();
}
canvas.refresh();
}
static createFallenLogSprite(scene, key = 'fallen_log') {
if (scene.textures.exists(key)) return;
const canvas = scene.textures.createCanvas(key, 48, 32);
const ctx = canvas.getContext();
ctx.clearRect(0, 0, 48, 32);
// Log body (horizontal)
ctx.fillStyle = '#8B4513';
ctx.fillRect(4, 14, 40, 10);
// Bark texture
ctx.fillStyle = '#654321';
for (let i = 0; i < 5; i++) {
ctx.fillRect(6 + i * 8, 14, 2, 10);
}
// Log rings (ends)
ctx.fillStyle = '#D2691E';
ctx.beginPath();
ctx.arc(6, 19, 5, 0, Math.PI * 2);
ctx.fill();
ctx.strokeStyle = '#654321';
ctx.lineWidth = 1;
ctx.beginPath();
ctx.arc(6, 19, 3, 0, Math.PI * 2);
ctx.stroke();
ctx.beginPath();
ctx.arc(6, 19, 1.5, 0, Math.PI * 2);
ctx.stroke();
// Small mushrooms growing on log
ctx.fillStyle = '#FF6347';
ctx.beginPath();
ctx.arc(20, 12, 3, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = '#FFE4C4';
ctx.fillRect(19, 13, 2, 3);
canvas.refresh();
}
static createPuddleSprite(scene, key = 'puddle') {
if (scene.textures.exists(key)) return;
const canvas = scene.textures.createCanvas(key, 32, 24);
const ctx = canvas.getContext();
ctx.clearRect(0, 0, 32, 24);
// Puddle shape (irregular oval)
ctx.fillStyle = 'rgba(70, 130, 180, 0.6)';
ctx.beginPath();
ctx.ellipse(16, 16, 12, 8, 0, 0, Math.PI * 2);
ctx.fill();
// Reflection highlights
ctx.fillStyle = 'rgba(255, 255, 255, 0.3)';
ctx.beginPath();
ctx.ellipse(12, 14, 4, 2, 0, 0, Math.PI * 2);
ctx.fill();
// Darker edge
ctx.strokeStyle = 'rgba(30, 60, 90, 0.5)';
ctx.lineWidth = 1;
ctx.beginPath();
ctx.ellipse(16, 16, 12, 8, 0, 0, Math.PI * 2);
ctx.stroke();
canvas.refresh();
}
static createScooterSprite(scene, key = 'scooter', isBroken = false) {
if (scene.textures.exists(key)) return;
const canvas = scene.textures.createCanvas(key, 48, 48);
const ctx = canvas.getContext();
ctx.clearRect(0, 0, 48, 48);
const color = isBroken ? '#696969' : '#FF4500'; // Rusty Gray vs OrangeRed
const wheelColor = '#1a1a1a';
// Wheels
ctx.fillStyle = wheelColor;
ctx.beginPath(); ctx.arc(12, 38, 5, 0, Math.PI * 2); ctx.fill(); // Back
ctx.beginPath(); ctx.arc(38, 38, 5, 0, Math.PI * 2); ctx.fill(); // Front
// Spokes
ctx.fillStyle = '#555';
ctx.beginPath(); ctx.arc(12, 38, 2, 0, Math.PI * 2); ctx.fill();
ctx.beginPath(); ctx.arc(38, 38, 2, 0, Math.PI * 2); ctx.fill();
// Base
ctx.fillStyle = color;
ctx.fillRect(12, 32, 26, 5); // Deck
// Angled Stem
ctx.beginPath();
ctx.moveTo(38, 34);
ctx.lineTo(34, 14);
ctx.lineTo(38, 14);
ctx.lineTo(42, 34);
ctx.closePath();
ctx.fill();
// Handlebars
ctx.strokeStyle = isBroken ? '#444' : '#C0C0C0';
ctx.lineWidth = 3;
ctx.beginPath();
ctx.moveTo(30, 14);
ctx.lineTo(42, 14);
ctx.stroke();
// Vertical post support
ctx.fillStyle = color;
ctx.fillRect(10, 30, 4, 4); // Rear wheel guard
if (isBroken) {
// Rust spots
ctx.fillStyle = '#8B4513';
ctx.fillRect(15, 33, 4, 2);
ctx.fillRect(35, 20, 2, 3);
}
canvas.refresh();
}
static createAnimatedWaterSprite(scene) {
// Create 4 separate textures for water animation frames
const frames = 4;
const frameWidth = 48;
const frameHeight = 60;
for (let f = 0; f < frames; f++) {
const key = `water_frame_${f}`;
if (scene.textures.exists(key)) continue;
const canvas = scene.textures.createCanvas(key, frameWidth, frameHeight);
const ctx = canvas.getContext();
ctx.clearRect(0, 0, frameWidth, frameHeight);
const P = 2;
const baseColor = 0x4444ff;
const shimmerOffset = Math.sin((f / frames) * Math.PI * 2) * 20;
const waterColor = Phaser.Display.Color.IntegerToColor(baseColor).lighten(shimmerOffset).color;
const xs = P;
const xe = 48 + P;
const midX = 24 + P;
const topY = P;
const midY = 12 + P;
const bottomY = 24 + P;
const depth = 20;
// Left Face
ctx.fillStyle = Phaser.Display.Color.IntegerToColor(waterColor).darken(30).rgba;
ctx.beginPath();
ctx.moveTo(midX, bottomY);
ctx.lineTo(midX, bottomY + depth);
ctx.lineTo(xs, midY + depth);
ctx.lineTo(xs, midY);
ctx.closePath();
ctx.fill();
// Right Face
ctx.fillStyle = Phaser.Display.Color.IntegerToColor(waterColor).darken(20).rgba;
ctx.beginPath();
ctx.moveTo(xe, midY);
ctx.lineTo(xe, midY + depth);
ctx.lineTo(midX, bottomY + depth);
ctx.lineTo(midX, bottomY);
ctx.closePath();
ctx.fill();
// Top Face
ctx.fillStyle = Phaser.Display.Color.IntegerToColor(waterColor).rgba;
ctx.beginPath();
ctx.moveTo(xs, midY);
ctx.lineTo(midX, topY);
ctx.lineTo(xe, midY);
ctx.lineTo(midX, bottomY);
ctx.closePath();
ctx.fill();
// Shimmer highlights
ctx.fillStyle = `rgba(255, 255, 255, ${0.1 + Math.abs(shimmerOffset) / 100})`;
for (let i = 0; i < 5; i++) {
const sx = xs + 8 + Math.random() * 28;
const sy = topY + 4 + Math.random() * 16;
ctx.fillRect(sx, sy, 3, 2);
}
// Wave lines
ctx.strokeStyle = `rgba(100, 100, 255, ${0.3 + (f / frames) * 0.2})`;
ctx.lineWidth = 1;
ctx.beginPath();
ctx.moveTo(xs + 10, midY + 8);
ctx.lineTo(xe - 10, midY - 2);
ctx.stroke();
canvas.refresh();
}
}
constructor(scene) {