- NEW: Flat2DTerrainSystem.js (375 lines) - NEW: map2d_data.js procedural map (221 lines) - MODIFIED: GameScene async create, 2D terrain integration - MODIFIED: Player.js flat 2D positioning - MODIFIED: game.js disabled pixelArt for smooth rendering - FIXED: 15+ bugs (updateCulling, isometric conversions, grid lines) - ADDED: Phase 28 to TASKS.md - DOCS: DNEVNIK.md session summary Result: Working flat 2D game with Stardew Valley style! Time: 5.5 hours
315 lines
6.6 KiB
Markdown
315 lines
6.6 KiB
Markdown
# 🌊 2D WATER & PUDDLES - ENHANCEMENT PLAN
|
|
|
|
## 📋 CURRENT STATUS
|
|
|
|
### ✅ What's Already Implemented:
|
|
|
|
**Water Animation:**
|
|
- ✅ 4-frame water animation (`createWaterFrames()`)
|
|
- ✅ Animated waves and sparkles
|
|
- ✅ Frame cycling (250ms intervals)
|
|
- ✅ Gradient (dark blue → medium blue)
|
|
|
|
**Puddles:**
|
|
- ✅ Basic ellipse shape (weather system)
|
|
- ✅ Fade in/out
|
|
- ✅ Splash ripples (concentric circles)
|
|
- ✅ Auto cleanup after 30s
|
|
|
|
---
|
|
|
|
## 🎯 ENHANCEMENT IDEAS
|
|
|
|
### 1. **Enhanced Water Animation**
|
|
|
|
#### A. Flow Direction
|
|
```javascript
|
|
// Add directional flow (left to right)
|
|
createFlowingWater() {
|
|
// Each frame shifts pattern slightly
|
|
// Creates illusion of water flowing
|
|
}
|
|
```
|
|
|
|
#### B. Reflection Effects
|
|
```javascript
|
|
// Add shimmer/reflection overlay
|
|
createWaterReflection() {
|
|
// Semi-transparent white overlay
|
|
// Moves independently from water
|
|
// Creates depth illusion
|
|
}
|
|
```
|
|
|
|
#### C. Ripple Waves
|
|
```javascript
|
|
// Add expanding circle ripples
|
|
createWaterRipples() {
|
|
// Periodic ripples from center
|
|
// Multiple overlapping waves
|
|
// Fades at edges
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
### 2. **Better Puddles**
|
|
|
|
#### A. Realistic Shape
|
|
```javascript
|
|
// Instead of perfect ellipse
|
|
createRealisticPuddle() {
|
|
// Irregular organic shape
|
|
// Multiple smaller circles merged
|
|
// Natural-looking edges
|
|
}
|
|
```
|
|
|
|
#### B. Rain Impact Animation
|
|
```javascript
|
|
// When raindrop hits puddle
|
|
onRainHit(puddleX, puddleY) {
|
|
// Small splash particle
|
|
// Ripple from impact point
|
|
// Temporary displacement wave
|
|
}
|
|
```
|
|
|
|
#### C. Reflection Layer
|
|
```javascript
|
|
// Add sky/environment reflection
|
|
addPuddleReflection(puddle) {
|
|
// Light blue tint (sky)
|
|
// Subtle animation (clouds moving)
|
|
// Adds depth and realism
|
|
}
|
|
```
|
|
|
|
#### D. Evaporation
|
|
```javascript
|
|
// Gradual shrinking over time
|
|
evaporatePuddle(puddle) {
|
|
// Scale reduces (puddle shrinks)
|
|
// Alpha fades
|
|
// Eventually disappears
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## 🔧 IMPLEMENTATION PRIORITY
|
|
|
|
### **HIGH PRIORITY:**
|
|
1. ✅ Water animation (already done!)
|
|
2. ⏳ Enhanced puddle shape (organic)
|
|
3. ⏳ Rain impact on puddles
|
|
|
|
### **MEDIUM PRIORITY:**
|
|
4. ⏳ Water reflection overlay
|
|
5. ⏳ Puddle reflections
|
|
6. ⏳ Evaporation animation
|
|
|
|
### **LOW PRIORITY:**
|
|
7. ⏳ Directional water flow
|
|
8. ⏳ Multiple ripple layers
|
|
9. ⏳ Foam/bubble effects
|
|
|
|
---
|
|
|
|
## 💻 CODE SNIPPETS
|
|
|
|
### Enhanced Puddle Creation:
|
|
```javascript
|
|
createRealisticPuddle(x, y) {
|
|
const container = this.scene.add.container(x, y);
|
|
|
|
// Create organic shape (multiple circles)
|
|
const numCircles = Phaser.Math.Between(3, 6);
|
|
for (let i = 0; i < numCircles; i++) {
|
|
const offsetX = Phaser.Math.Between(-15, 15);
|
|
const offsetY = Phaser.Math.Between(-10, 10);
|
|
const radius = Phaser.Math.Between(10, 20);
|
|
|
|
const circle = this.scene.add.circle(
|
|
offsetX, offsetY, radius,
|
|
0x4488bb, 0.35
|
|
);
|
|
container.add(circle);
|
|
}
|
|
|
|
// Add reflection overlay (lighter blue)
|
|
const reflection = this.scene.add.ellipse(
|
|
0, -5, 30, 15,
|
|
0x88ccff, 0.2
|
|
);
|
|
container.add(reflection);
|
|
|
|
// Fade in
|
|
container.setAlpha(0);
|
|
this.scene.tweens.add({
|
|
targets: container,
|
|
alpha: 1,
|
|
duration: 2000
|
|
});
|
|
|
|
return container;
|
|
}
|
|
```
|
|
|
|
### Rain Impact on Puddle:
|
|
```javascript
|
|
addRainImpact(puddle) {
|
|
// Random splash position within puddle
|
|
const hitX = Phaser.Math.Between(-20, 20);
|
|
const hitY = Phaser.Math.Between(-15, 15);
|
|
|
|
// Create ripple
|
|
const ripple = this.scene.add.circle(
|
|
puddle.x + hitX,
|
|
puddle.y + hitY,
|
|
2, 0xffffff, 0.6
|
|
);
|
|
|
|
this.scene.tweens.add({
|
|
targets: ripple,
|
|
radius: 15,
|
|
alpha: 0,
|
|
duration: 600,
|
|
onComplete: () => ripple.destroy()
|
|
});
|
|
}
|
|
```
|
|
|
|
### Water Reflection Overlay:
|
|
```javascript
|
|
addWaterReflection(waterSprite) {
|
|
// Create shimmer overlay
|
|
const shimmer = this.scene.add.rectangle(
|
|
waterSprite.x,
|
|
waterSprite.y - 5,
|
|
48, 10,
|
|
0xffffff, 0.15
|
|
);
|
|
shimmer.setDepth(waterSprite.depth + 1);
|
|
|
|
// Animate shimmer movement
|
|
this.scene.tweens.add({
|
|
targets: shimmer,
|
|
x: waterSprite.x + 10,
|
|
alpha: { from: 0.15, to: 0.05 },
|
|
duration: 2000,
|
|
yoyo: true,
|
|
repeat: -1
|
|
});
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## 🎮 USAGE
|
|
|
|
### Current Water:
|
|
```javascript
|
|
// Water already animates automatically!
|
|
// 4-frame cycle, 250ms per frame
|
|
// No user action needed
|
|
```
|
|
|
|
### Enhanced Puddles (Proposed):
|
|
```javascript
|
|
// In GameScene weather system
|
|
if (this.currentWeather === 'rain') {
|
|
// Spawn better puddle every 3s
|
|
this.puddleTimer = this.time.addEvent({
|
|
delay: 3000,
|
|
callback: () => {
|
|
const puddle = this.createRealisticPuddle(x, y);
|
|
|
|
// Add rain impact effects
|
|
this.time.addEvent({
|
|
delay: 1000,
|
|
callback: () => this.addRainImpact(puddle),
|
|
loop: true,
|
|
repeat: 10
|
|
});
|
|
},
|
|
loop: true
|
|
});
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
## 📊 PERFORMANCE NOTES
|
|
|
|
### Current Performance:
|
|
- **Water:** ~50 water tiles visible (4 frames each) = Good ✅
|
|
- **Puddles:** Max 20 puddles = Good ✅
|
|
|
|
### After Enhancements:
|
|
- **Water Reflections:** +50 shimmer overlays = Medium ⚠️
|
|
- **Puddle Complexity:** 5 circles each = Medium ⚠️
|
|
- **Rain Impacts:** Up to 100 ripples/sec = High ⚠️
|
|
|
|
**Recommendation:**
|
|
- Use object pooling for ripples
|
|
- Limit max puddles to 15
|
|
- Reduce ripple frequency if FPS drops
|
|
|
|
---
|
|
|
|
## 🎨 VISUAL COMPARISON
|
|
|
|
### Current:
|
|
```
|
|
WATER:
|
|
[████] Frame 1
|
|
[▓▓▓▓] Frame 2 ← Animated!
|
|
[████] Frame 3
|
|
[▓▓▓▓] Frame 4
|
|
|
|
PUDDLES:
|
|
○○○ ← Simple ellipse
|
|
```
|
|
|
|
### After Enhancement:
|
|
```
|
|
WATER:
|
|
[████✨] Frame 1 + Reflection
|
|
[▓▓▓▓✨] Frame 2 + Shimmer
|
|
[████✨] Frame 3 + Waves
|
|
[▓▓▓▓✨] Frame 4 + Flow
|
|
|
|
PUDDLES:
|
|
○ ○
|
|
○ ○ ○ ← Organic shape
|
|
○ ○ + Reflections
|
|
~~~ + Ripples
|
|
```
|
|
|
|
---
|
|
|
|
## ✅ NEXT STEPS
|
|
|
|
1. **Review current water** - Check if enhancement needed
|
|
2. **Implement organic puddles** - Better looking shapes
|
|
3. **Add rain impacts** - Ripples when rain hits
|
|
4. **Test performance** - Monitor FPS with many puddles
|
|
5. **Fine-tune** - Adjust timings, sizes, opacity
|
|
|
|
---
|
|
|
|
## 📁 FILES TO MODIFY
|
|
|
|
- `src/systems/TerrainSystem.js` - Water frames enhancement
|
|
- `src/scenes/GameScene.js` - Puddle system upgrade
|
|
- `src/ui/WeatherUI.js` - Optional: puddle toggle
|
|
|
|
---
|
|
|
|
**Status:** 📋 Planning Phase
|
|
**Current Water:** ✅ Already Animated
|
|
**Current Puddles:** ✅ Basic Working
|
|
**Next:** User decision on enhancements
|
|
|