package components

import (
	. "openquell/config"
)

// movement in relation to position
type Velocity struct {
	Data      Position
	Direction int
}

func (velocity *Velocity) Change(direction int) {
	ticks := 4

	switch direction {
	case East:
		velocity.Data.X = ticks
		velocity.Data.Y = 0
	case West:
		velocity.Data.X = ticks - (ticks * 2)
		velocity.Data.Y = 0
	case South:
		velocity.Data.X = 0
		velocity.Data.Y = ticks
	case North:
		velocity.Data.X = 0
		velocity.Data.Y = ticks - (ticks * 2)
	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
}
