You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
696 B
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
|
|
}
|