2022-06-18 21:08:53 +00:00
|
|
|
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 {
|
2022-06-29 04:45:31 +00:00
|
|
|
if world.GameOver {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-06-18 21:08:53 +00:00
|
|
|
world.Space.Step(1.0 / world.TPS)
|
2022-06-28 00:42:56 +00:00
|
|
|
world.PlayerBody.SetAngle(0)
|
|
|
|
world.PlayerBody.SetAngularVelocity(0)
|
2022-06-28 18:56:02 +00:00
|
|
|
|
|
|
|
world.Tick++
|
2022-06-18 21:08:53 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *PhysicsSystem) Draw(e gohan.Entity, screen *ebiten.Image) error {
|
|
|
|
return gohan.ErrUnregister
|
|
|
|
}
|