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) {
|
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 {
|
func (p *Player) Update(e *gx.Engine) error {
|
||||||
|
@ -84,12 +86,14 @@ func (p *Player) Update(e *gx.Engine) error {
|
||||||
} else {
|
} else {
|
||||||
c.Object.T.RA.X += gx.Pi * p.MoveSpeed * dt
|
c.Object.T.RA.X += gx.Pi * p.MoveSpeed * dt
|
||||||
}
|
}
|
||||||
|
log.Println(c.Object.T.RA.X)
|
||||||
case ebiten.KeyX :
|
case ebiten.KeyX :
|
||||||
if e.KeyIsPressed(ebiten.KeyShift) {
|
if e.KeyIsPressed(ebiten.KeyShift) {
|
||||||
c.Object.T.RA.Y -= gx.Pi * p.MoveSpeed * dt
|
c.Object.T.RA.Y -= gx.Pi * p.MoveSpeed * dt
|
||||||
} else {
|
} else {
|
||||||
c.Object.T.RA.Y += gx.Pi * p.MoveSpeed * dt
|
c.Object.T.RA.Y += gx.Pi * p.MoveSpeed * dt
|
||||||
}
|
}
|
||||||
|
log.Println(c.Object.T.RA.Y)
|
||||||
}}
|
}}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -66,6 +66,7 @@ func (e *Engine) Add(l Layer, b any) {
|
||||||
beh, ok := b.(Behaver)
|
beh, ok := b.(Behaver)
|
||||||
if ok {
|
if ok {
|
||||||
e.AddBehaver(beh)
|
e.AddBehaver(beh)
|
||||||
|
beh.Start(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
drw, ok := b.(Drawer)
|
drw, ok := b.(Drawer)
|
||||||
|
|
|
@ -18,6 +18,10 @@ type Transform struct {
|
||||||
R Float
|
R Float
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func V(x, y Float) Vector {
|
||||||
|
return Vector{x, y}
|
||||||
|
}
|
||||||
|
|
||||||
func T() Transform {
|
func T() Transform {
|
||||||
ret := Transform{}
|
ret := Transform{}
|
||||||
return ret
|
return ret
|
||||||
|
|
Loading…
Reference in a new issue