obstacle collission added, but not working yet
This commit is contained in:
@@ -72,7 +72,13 @@ func (position *Position) String() string {
|
||||
}
|
||||
|
||||
func (position *Position) Move(velocity *Velocity, speed *Speed) {
|
||||
position.Update(position.X+(velocity.Data.X*speed.Value), position.Y+(velocity.Data.Y*speed.Value))
|
||||
if velocity.Direction != 0 {
|
||||
slog.Debug("moving", "velocity", velocity, "speed", speed)
|
||||
}
|
||||
position.Update(
|
||||
position.X+(velocity.Data.X*speed.Value),
|
||||
position.Y+(velocity.Data.Y*speed.Value),
|
||||
)
|
||||
}
|
||||
|
||||
func (position *Position) Set(newpos *Position) {
|
||||
|
||||
@@ -35,3 +35,21 @@ func (velocity *Velocity) Change(direction int) {
|
||||
func (velocity *Velocity) Moving() bool {
|
||||
return velocity.Data.X != 0 || velocity.Data.Y != 0
|
||||
}
|
||||
|
||||
func (velocity *Velocity) InvertDirection() int {
|
||||
switch velocity.Direction {
|
||||
case East:
|
||||
return West
|
||||
case West:
|
||||
return East
|
||||
case South:
|
||||
return North
|
||||
case North:
|
||||
return South
|
||||
case All:
|
||||
return Stop
|
||||
}
|
||||
|
||||
// should not happen
|
||||
return All
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user