improve collision detection

This commit is contained in:
Luke Meyers 2020-02-05 20:36:41 -08:00
parent 14aabd1b45
commit e727d74e78
1 changed files with 4 additions and 3 deletions

View File

@ -22,9 +22,10 @@ func moveBot(b *Bot, s State) {
b.v = -maxV b.v = -maxV
} }
newPos := b.Pos + b.v for i := 0; i < b.v; i++ {
if !collide(b.id, newPos, b.Lane, s) { if !collide(b.id, b.Pos+1, b.Lane, s) {
b.Pos = newPos b.Pos++
}
} }
} }