doctorlectro/system/physics.go

39 lines
696 B
Go

package system
import (
_ "image/png"
"code.rocketnine.space/tslocum/doctorlectro/world"
"code.rocketnine.space/tslocum/doctorlectro/component"
"code.rocketnine.space/tslocum/gohan"
"github.com/hajimehoshi/ebiten/v2"
)
type PhysicsSystem struct {
Player *component.Player
}
func NewPhysicsSystem() *PhysicsSystem {
s := &PhysicsSystem{}
return s
}
func (s *PhysicsSystem) Update(_ gohan.Entity) error {
if world.GameOver {
return nil
}
world.Space.Step(1.0 / world.TPS)
world.PlayerBody.SetAngle(0)
world.PlayerBody.SetAngularVelocity(0)
world.Tick++
return nil
}
func (s *PhysicsSystem) Draw(e gohan.Entity, screen *ebiten.Image) error {
return gohan.ErrUnregister
}