From e727d74e785530426a199bedf51afe86e163d7ee Mon Sep 17 00:00:00 2001 From: Luke Meyers Date: Wed, 5 Feb 2020 20:36:41 -0800 Subject: [PATCH] improve collision detection --- game/physics.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/game/physics.go b/game/physics.go index fcb87c9..80aaa09 100644 --- a/game/physics.go +++ b/game/physics.go @@ -22,9 +22,10 @@ func moveBot(b *Bot, s State) { b.v = -maxV } - newPos := b.Pos + b.v - if !collide(b.id, newPos, b.Lane, s) { - b.Pos = newPos + for i := 0; i < b.v; i++ { + if !collide(b.id, b.Pos+1, b.Lane, s) { + b.Pos++ + } } }