obstacle collission added, but not working yet

This commit is contained in:
2024-02-20 18:47:32 +01:00
parent fd570216f0
commit 646b227b8e
15 changed files with 112 additions and 21 deletions

View File

@@ -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) {

View File

@@ -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
}