mirror of
https://github.com/stevenhowes/GoRetro.git
synced 2026-05-27 00:03:29 +01:00
Move all engine stuff to GoRetro. Still many interactions between game and engine code that there should not be.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package GoRetro
|
||||
|
||||
/*
|
||||
* --------------------
|
||||
* moverLinear
|
||||
* --------------------
|
||||
* A simple mover that moves the container a fixed
|
||||
* distance each tick in the direction of its rotation
|
||||
*/
|
||||
|
||||
import (
|
||||
"math"
|
||||
)
|
||||
|
||||
type moverLinear struct {
|
||||
container *Element
|
||||
speed float64
|
||||
}
|
||||
|
||||
func NewMoverLinear(container *Element, speed float64) *moverLinear {
|
||||
return &moverLinear{container: container, speed: speed}
|
||||
}
|
||||
|
||||
func (mover *moverLinear) onDraw() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mover *moverLinear) onUpdate() error {
|
||||
c := mover.container
|
||||
|
||||
// Move, taking into account rotation in degrees
|
||||
c.Position.X += mover.speed * math.Sin(c.Rotation*(math.Pi/180)) * Delta
|
||||
c.Position.Y += mover.speed * math.Cos(c.Rotation*(math.Pi/180)) * Delta
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mover *moverLinear) onCollision(other *Element) error {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user