From a493e7ab18943530fa21b33959040d0c6c7dccd2 Mon Sep 17 00:00:00 2001 From: Rob Holland Date: Fri, 6 Sep 2024 14:27:44 +0100 Subject: [PATCH] Make the snakes change slightly less often. --- snakes/src/lib/pages/SnakeRoundPage.svelte | 2 +- snakes/src/lib/snake/SnakeBody.ts | 3 ++- snakes/src/lib/snake/types.ts | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/snakes/src/lib/pages/SnakeRoundPage.svelte b/snakes/src/lib/pages/SnakeRoundPage.svelte index b536c10..b676992 100644 --- a/snakes/src/lib/pages/SnakeRoundPage.svelte +++ b/snakes/src/lib/pages/SnakeRoundPage.svelte @@ -39,7 +39,7 @@ timerInterval = setInterval(updateTimer, 1000); if (isDemo) { - demoInterval = setInterval(moveRandomSnake, 50); + demoInterval = setInterval(moveRandomSnake, 100); } } diff --git a/snakes/src/lib/snake/SnakeBody.ts b/snakes/src/lib/snake/SnakeBody.ts index 9a3dfe5..55fbc54 100644 --- a/snakes/src/lib/snake/SnakeBody.ts +++ b/snakes/src/lib/snake/SnakeBody.ts @@ -48,7 +48,7 @@ export default class SnakeBody { } redraw(segments: Segment[]) { - this.snake.segments.forEach((segment, index) => { + this.snake.segments.forEach((segment) => { let { x, y, w, h } = this.calculateRect(segment); this.context.clearRect(x, y, w, h); }); @@ -63,6 +63,7 @@ export default class SnakeBody { const head = index === 0; let { x, y, w, h } = this.calculateRect(segment); this.context.fillRect(x, y, w, h); + if (head) { const locations: Record = { "up": [[0.25, 0.25],[0.75, 0.25]], diff --git a/snakes/src/lib/snake/types.ts b/snakes/src/lib/snake/types.ts index 5f7cb15..df3877c 100644 --- a/snakes/src/lib/snake/types.ts +++ b/snakes/src/lib/snake/types.ts @@ -45,7 +45,7 @@ export type Round = { startedAt?: number; finished?: boolean; }; - + export type Point = { x: number; y: number;