Private
Public Access
1
0

- Refactor dirt and stone generation to optimize visible depth and adjust randomization.
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 8m32s

- Remove unused `StartWebSocketGateway` function from `websocket_gateway.go`.
- Add security checks to track player-room mapping, enforce valid input, and prevent ID spoofing in `gateway.go`.
- Refactor touch control logic to dynamically position joystick and buttons above gameplay floor.
- Introduce dynamic floor Y-coordinate calculation (`GetFloorYFromHeight`) for better scaling across different screen sizes.
- Adjust rendering logic to align assets, particles, and debug visuals with dynamic screen height transformations.
- Update canvas CSS to support fullscreen scaling without center alignment.
This commit is contained in:
Sebastian Unterschütz
2026-01-09 21:34:24 +01:00
parent d156dce2e7
commit 4be6cc791e
10 changed files with 250 additions and 77 deletions

View File

@@ -58,27 +58,27 @@ func GenerateGroundTile(tileIdx int) GroundTile {
Stones: make([]Stone, 0),
}
// Zufällige Dirt-Patches generieren (20-30 pro Tile, über die ganze Höhe)
numDirt := 20 + rng.Intn(10)
dirtHeight := 5000.0 // Gesamte Dirt-Höhe bis tief in die Erde
// Zufällige Dirt-Patches generieren (15-25 pro Tile, kompakt)
numDirt := 15 + rng.Intn(10)
maxDirtHeight := 100.0 // Kompakte Erde-Tiefe (100px)
for i := 0; i < numDirt; i++ {
darkness := uint8(70 + rng.Intn(40)) // Verschiedene Brauntöne
tile.DirtVariants = append(tile.DirtVariants, DirtPatch{
OffsetX: rng.Float64() * 128,
OffsetY: rng.Float64()*dirtHeight + 20, // Über die ganze Dirt-Schicht verteilt
OffsetY: rng.Float64()*maxDirtHeight + 20, // Nur im sichtbaren Bereich
Width: 10 + rng.Float64()*30,
Height: 10 + rng.Float64()*25,
Color: color.RGBA{darkness, darkness - 10, darkness - 20, 255},
})
}
// Steine IN der Erde generieren (30-50 pro Tile, nur eckig, tief verteilt)
numStones := 30 + rng.Intn(20)
// Steine IN der Erde generieren (20-30 pro Tile, nur eckig, kompakt)
numStones := 20 + rng.Intn(10)
for i := 0; i < numStones; i++ {
tile.Stones = append(tile.Stones, Stone{
X: rng.Float64() * 128,
Y: rng.Float64()*dirtHeight + 20, // Tief in der Erde verteilt
Size: 4 + rng.Float64()*8, // Verschiedene Größen
Y: rng.Float64()*maxDirtHeight + 20, // Nur im sichtbaren Bereich
Size: 4 + rng.Float64()*8, // Verschiedene Größen
Color: color.RGBA{100 + uint8(rng.Intn(50)), 100 + uint8(rng.Intn(50)), 100 + uint8(rng.Intn(50)), 255},
Shape: 1, // Nur eckig (keine runden Steine mehr)
})
@@ -92,18 +92,28 @@ func GenerateGroundTile(tileIdx int) GroundTile {
// RenderGround rendert den Boden mit Bewegung
func (g *Game) RenderGround(screen *ebiten.Image, cameraX float64) {
// Tatsächliche Canvas-Größe verwenden
canvasW, _ := screen.Size()
canvasW, canvasH := screen.Size()
// Boden bleibt an fester Position (RefFloorY) - wichtig für Spielphysik!
// Erweitere Boden nach unten weit über Canvas-Rand hinaus (5000 Pixel tief)
floorY := float32(RefFloorY)
floorH := float32(5000) // Tief in die Erde
// Gameplay-Boden-Position (wo Spieler laufen) - mit echter Canvas-Höhe!
gameFloorY := float32(GetFloorYFromHeight(canvasH))
// Erde-Tiefe - kompakt (100px) damit Gameplay optimal Platz hat
maxDirtDepth := float32(100.0)
// Berechne wie viel Erde sichtbar sein soll (bis zum Bildschirmrand)
remainingSpace := float32(canvasH) - gameFloorY
visibleDirtHeight := maxDirtDepth
if remainingSpace < maxDirtDepth {
visibleDirtHeight = remainingSpace
}
// 1. Basis Gras-Schicht (volle Canvas-Breite, nur dünne Grasnarbe)
vector.DrawFilledRect(screen, 0, floorY, float32(canvasW), 20, ColGrass, false)
vector.DrawFilledRect(screen, 0, gameFloorY, float32(canvasW), 20, ColGrass, false)
// 2. Dirt-Schicht (Basis, volle Canvas-Breite, tief nach unten)
vector.DrawFilledRect(screen, 0, floorY+20, float32(canvasW), floorH-20, ColDirt, false)
// 2. Dirt-Schicht (Basis, volle Canvas-Breite, nur sichtbarer Bereich)
if visibleDirtHeight > 20 {
vector.DrawFilledRect(screen, 0, gameFloorY+20, float32(canvasW), visibleDirtHeight-20, ColDirt, false)
}
// 3. Prozedurale Dirt-Patches und Steine (bewegen sich mit Kamera)
// Berechne welche Tiles sichtbar sind (basierend auf Canvas-Breite)
@@ -119,7 +129,7 @@ func (g *Game) RenderGround(screen *ebiten.Image, cameraX float64) {
for _, dirt := range tile.DirtVariants {
worldX := tile.X + dirt.OffsetX
screenX := float32(worldX - cameraX)
screenY := float32(RefFloorY) + float32(dirt.OffsetY)
screenY := gameFloorY + float32(dirt.OffsetY)
// Nur rendern wenn im sichtbaren Bereich (Canvas-Breite verwenden)
if screenX+float32(dirt.Width) > 0 && screenX < float32(canvasW) {
@@ -127,11 +137,11 @@ func (g *Game) RenderGround(screen *ebiten.Image, cameraX float64) {
}
}
// Steine rendern (auf dem Gras)
// Steine rendern (in der Erde)
for _, stone := range tile.Stones {
worldX := tile.X + stone.X
screenX := float32(worldX - cameraX)
screenY := float32(RefFloorY) + float32(stone.Y)
screenY := gameFloorY + float32(stone.Y)
// Nur rendern wenn im sichtbaren Bereich (Canvas-Breite verwenden)
if screenX > -20 && screenX < float32(canvasW)+20 {