Run the "start" function on adding objects.
This commit is contained in:
parent
02a6cc3e88
commit
e03c1479e2
3 changed files with 9 additions and 0 deletions
|
@ -38,6 +38,8 @@ func NewPlayer() *Player {
|
|||
}
|
||||
|
||||
func (p *Player) Start(e *gx.Engine) {
|
||||
c := e.Camera()
|
||||
c.Object.T.RA = gx.V(360, -120)
|
||||
}
|
||||
|
||||
func (p *Player) Update(e *gx.Engine) error {
|
||||
|
@ -84,12 +86,14 @@ func (p *Player) Update(e *gx.Engine) error {
|
|||
} else {
|
||||
c.Object.T.RA.X += gx.Pi * p.MoveSpeed * dt
|
||||
}
|
||||
log.Println(c.Object.T.RA.X)
|
||||
case ebiten.KeyX :
|
||||
if e.KeyIsPressed(ebiten.KeyShift) {
|
||||
c.Object.T.RA.Y -= gx.Pi * p.MoveSpeed * dt
|
||||
} else {
|
||||
c.Object.T.RA.Y += gx.Pi * p.MoveSpeed * dt
|
||||
}
|
||||
log.Println(c.Object.T.RA.Y)
|
||||
}}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -66,6 +66,7 @@ func (e *Engine) Add(l Layer, b any) {
|
|||
beh, ok := b.(Behaver)
|
||||
if ok {
|
||||
e.AddBehaver(beh)
|
||||
beh.Start(e)
|
||||
}
|
||||
|
||||
drw, ok := b.(Drawer)
|
||||
|
|
|
@ -18,6 +18,10 @@ type Transform struct {
|
|||
R Float
|
||||
}
|
||||
|
||||
func V(x, y Float) Vector {
|
||||
return Vector{x, y}
|
||||
}
|
||||
|
||||
func T() Transform {
|
||||
ret := Transform{}
|
||||
return ret
|
||||
|
|
Loading…
Reference in a new issue