diff --git a/pic_large.png b/pic_large.png new file mode 100644 index 0000000..918441f Binary files /dev/null and b/pic_large.png differ diff --git a/pic_small.png b/pic_small.png new file mode 100644 index 0000000..1939d22 Binary files /dev/null and b/pic_small.png differ diff --git a/src/index.html b/src/index.html index 748ba52..6ac3544 100644 --- a/src/index.html +++ b/src/index.html @@ -14,7 +14,6 @@ image-rendering: crisp-edges; image-rendering: optimizespeed; background: #73b08a; - background-image: url('grass.png'); } canvas { diff --git a/src/index.js b/src/index.js index 6532c78..c993153 100644 --- a/src/index.js +++ b/src/index.js @@ -150,15 +150,15 @@ const checkCollisions = (ant, otherAnts) => { const updateDirection = (ant, chance, canvasCache) => { if (canvasCache) { - if (ant.angleDelta > 0) { - const delta = Math.min(angleDeltaStep, ant.angleDelta) - ant.angle += delta - ant.angleDelta -= delta - } else if (ant.angleDelta < 0) { - const delta = Math.max(-angleDeltaStep, ant.angleDelta) - ant.angle += delta - ant.angleDelta -= delta - } + // if (ant.angleDelta > 0) { + // const delta = Math.min(angleDeltaStep, ant.angleDelta) + // ant.angle += delta + // ant.angleDelta -= delta + // } else if (ant.angleDelta < 0) { + // const delta = Math.max(-angleDeltaStep, ant.angleDelta) + // ant.angle += delta + // ant.angleDelta -= delta + // } const front = getPixel( ant.x + ant.dx * lookoutDistance, @@ -183,13 +183,13 @@ const updateDirection = (ant, chance, canvasCache) => { const turnChance = Math.random() if (rightBlueness > leftBlueness && rightBlueness > turnChance) { - // ant.angle = ant.angle - lookoutAngle / 3 - ant.angleDelta = -lookoutAngle / 3 + ant.angle = ant.angle - lookoutAngle / 3 + // ant.angleDelta = -lookoutAngle / 3 ant.dx = ant.speed * Math.cos(degToRad(ant.angle)) ant.dy = ant.speed * Math.sin(degToRad(ant.angle)) } else if (leftBlueness > rightBlueness && leftBlueness > turnChance) { - // ant.angle = ant.angle + lookoutAngle / 3 - ant.angleDelta = lookoutAngle / 3 + ant.angle = ant.angle + lookoutAngle / 3 + // ant.angleDelta = lookoutAngle / 3 ant.dx = ant.speed * Math.cos(degToRad(ant.angle)) ant.dy = ant.speed * Math.sin(degToRad(ant.angle)) } @@ -197,8 +197,8 @@ const updateDirection = (ant, chance, canvasCache) => { // Random change of direction if (Math.random() < chance) { - // ant.angle = ant.angle + (Math.random() * change * 2 - change) - ant.angleDelta = Math.random() * change * 2 - change + ant.angle = ant.angle + (Math.random() * change * 2 - change) + // ant.angleDelta = Math.random() * change * 2 - change ant.dx = ant.speed * Math.cos(degToRad(ant.angle)) ant.dy = ant.speed * Math.sin(degToRad(ant.angle)) }