package components import ( . "openquell/config" ) // movement in relation to position type Velocity struct { Data Position Direction int } func (velocity *Velocity) Change(direction int) { switch direction { case East: velocity.Data.X = 1 velocity.Data.Y = 0 case West: velocity.Data.X = -1 velocity.Data.Y = 0 case South: velocity.Data.X = 0 velocity.Data.Y = 1 case North: velocity.Data.X = 0 velocity.Data.Y = -1 case Stop: velocity.Data.X = 0 velocity.Data.Y = 0 } velocity.Direction = direction } func (velocity *Velocity) Moving() bool { return velocity.Data.X != 0 || velocity.Data.Y != 0 }