Lagt till bas-karta med sky-blue bakgrund och fungerande plattformshopp

This commit is contained in:
2026-04-25 23:21:56 +02:00
parent 56934135ab
commit b250629e34
2 changed files with 114 additions and 17 deletions

View File

@@ -0,0 +1,26 @@
package scenes
import (
"github.com/go-gl/mathgl/mgl64"
"github.com/hajimehoshi/ebiten/v2"
)
type Platform struct {
Pos mgl64.Vec3
Width float64
Height float64
Sprite *ebiten.Image
Scale float64
}
// Kolla ifall spelaren nuddar ovansidan av plattformen (Fallande)
func (p *Platform) CheckCollisionTop(player *Player, nextY float64) bool {
// AABB (Axis-Aligned Bounding Box) X-kollision
if player.Pos[0] < p.Pos[0]+(p.Width*p.Scale) && player.Pos[0]+player.Width > p.Pos[0] {
// Kolla om spelaren är på väg ner och "korsar" toppen av plattformen
if player.Pos[1]+player.Height <= p.Pos[1] && nextY+player.Height >= p.Pos[1] {
return true
}
}
return false
}