From d9f3730b4d4b7ce047fa1cb0baa09198cd07f540 Mon Sep 17 00:00:00 2001 From: "Martin M. S. Pedersen" Date: Mon, 10 Jun 2019 19:38:25 +0200 Subject: [PATCH] Add pipe's width when bird is looking for closest pipe --- examples/neuroevolution-flappybird/bird.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/neuroevolution-flappybird/bird.js b/examples/neuroevolution-flappybird/bird.js index 2cccc5b..2cfa5db 100644 --- a/examples/neuroevolution-flappybird/bird.js +++ b/examples/neuroevolution-flappybird/bird.js @@ -62,7 +62,7 @@ class Bird { let closest = null; let record = Infinity; for (let i = 0; i < pipes.length; i++) { - let diff = pipes[i].x - this.x; + let diff = pipes[i].x - this.x + pipes[i].w; if (diff > 0 && diff < record) { record = diff; closest = pipes[i]; @@ -111,4 +111,4 @@ class Bird { // Every frame it is alive increases the score this.score++; } -} \ No newline at end of file +}