Private
Public Access
1
0

Integrate shared physics engine for player movement and collision handling, refine 20 TPS gameplay logic, and enhance client prediction with server-reconciliation updates.
All checks were successful
Dynamic Branch Deploy / build-and-deploy (push) Successful in 7m51s

This commit is contained in:
Sebastian Unterschütz
2026-01-06 21:37:32 +01:00
parent 23d42d42e7
commit 023996229a
13 changed files with 685 additions and 251 deletions

View File

@@ -58,9 +58,9 @@ func GenerateGroundTile(tileIdx int) GroundTile {
Stones: make([]Stone, 0),
}
// Zufällige Dirt-Patches generieren (15-25 pro Tile, über die ganze Höhe)
numDirt := 15 + rng.Intn(10)
dirtHeight := float64(ScreenHeight - RefFloorY - 20) // Gesamte Dirt-Höhe
// 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
for i := 0; i < numDirt; i++ {
darkness := uint8(70 + rng.Intn(40)) // Verschiedene Brauntöne
tile.DirtVariants = append(tile.DirtVariants, DirtPatch{
@@ -72,7 +72,17 @@ func GenerateGroundTile(tileIdx int) GroundTile {
})
}
// Keine Steine mehr auf dem Gras
// Steine IN der Erde generieren (10-20 pro Tile, tief verteilt)
numStones := 10 + 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
Color: color.RGBA{100 + uint8(rng.Intn(50)), 100 + uint8(rng.Intn(50)), 100 + uint8(rng.Intn(50)), 255},
Shape: rng.Intn(2), // 0=rund, 1=eckig
})
}
// In Cache speichern
groundCache[tileIdx] = tile
@@ -81,20 +91,25 @@ 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()
// 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(ScreenHeight - RefFloorY)
floorH := float32(5000) // Tief in die Erde
// 1. Basis Gras-Schicht
vector.DrawFilledRect(screen, 0, floorY, float32(ScreenWidth), floorH, ColGrass, false)
// 1. Basis Gras-Schicht (volle Canvas-Breite, nur dünne Grasnarbe)
vector.DrawFilledRect(screen, 0, floorY, float32(canvasW), 20, ColGrass, false)
// 2. Dirt-Schicht (Basis)
vector.DrawFilledRect(screen, 0, floorY+20, float32(ScreenWidth), floorH-20, ColDirt, false)
// 2. Dirt-Schicht (Basis, volle Canvas-Breite, tief nach unten)
vector.DrawFilledRect(screen, 0, floorY+20, float32(canvasW), floorH-20, ColDirt, false)
// 3. Prozedurale Dirt-Patches und Steine (bewegen sich mit Kamera)
// Berechne welche Tiles sichtbar sind
// Berechne welche Tiles sichtbar sind (basierend auf Canvas-Breite)
tileWidth := 128.0
startTile := int(math.Floor(cameraX / tileWidth))
endTile := int(math.Ceil((cameraX + float64(ScreenWidth)) / tileWidth))
endTile := int(math.Ceil((cameraX + float64(canvasW)) / tileWidth))
// Tiles rendern
for tileIdx := startTile; tileIdx <= endTile; tileIdx++ {
@@ -106,8 +121,8 @@ func (g *Game) RenderGround(screen *ebiten.Image, cameraX float64) {
screenX := float32(worldX - cameraX)
screenY := float32(RefFloorY) + float32(dirt.OffsetY)
// Nur rendern wenn im sichtbaren Bereich
if screenX+float32(dirt.Width) > 0 && screenX < float32(ScreenWidth) {
// Nur rendern wenn im sichtbaren Bereich (Canvas-Breite verwenden)
if screenX+float32(dirt.Width) > 0 && screenX < float32(canvasW) {
vector.DrawFilledRect(screen, screenX, screenY, float32(dirt.Width), float32(dirt.Height), dirt.Color, false)
}
}
@@ -118,8 +133,8 @@ func (g *Game) RenderGround(screen *ebiten.Image, cameraX float64) {
screenX := float32(worldX - cameraX)
screenY := float32(RefFloorY) + float32(stone.Y)
// Nur rendern wenn im sichtbaren Bereich
if screenX > -20 && screenX < float32(ScreenWidth)+20 {
// Nur rendern wenn im sichtbaren Bereich (Canvas-Breite verwenden)
if screenX > -20 && screenX < float32(canvasW)+20 {
if stone.Shape == 0 {
// Runder Stein
vector.DrawFilledCircle(screen, screenX, screenY, float32(stone.Size/2), stone.Color, false)