26 lines
527 B
Go
26 lines
527 B
Go
package physics
|
|
|
|
// Entity repräsentiert alles, was sich bewegt (Spieler, Hindernis)
|
|
type Entity struct {
|
|
X, Y float64
|
|
Width, Height float64
|
|
VelocityY float64
|
|
}
|
|
|
|
// Config für Konstanten (Schwerkraft etc.)
|
|
type Config struct {
|
|
Gravity float64
|
|
Speed float64
|
|
}
|
|
|
|
// Update simuliert einen Tick (z.B. 1/60 sekunde)
|
|
func (e *Entity) Update(cfg Config) {
|
|
e.VelocityY += cfg.Gravity
|
|
e.Y += e.VelocityY
|
|
// Einfache Boden-Kollision (Hardcoded für den Anfang)
|
|
if e.Y > 300 {
|
|
e.Y = 300
|
|
e.VelocityY = 0
|
|
}
|
|
}
|