From 225e5e842209649d5e934f97440e3e7f0b8613bb Mon Sep 17 00:00:00 2001 From: Trianta <56975502+Trimutex@users.noreply.github.com> Date: Mon, 30 Dec 2024 17:15:41 -0600 Subject: [PATCH] pong: reset counter on idle and increase idle length --- src/pong.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pong.ts b/src/pong.ts index d46b19a..db79bcc 100644 --- a/src/pong.ts +++ b/src/pong.ts @@ -256,10 +256,11 @@ class PongCore { // Randomly move the bot paddle when ball not towards it botIdle(player: Paddle) { - if (player.idleCounter < 10) { - player.idleCounter++; + player.idleCounter++; + if (player.idleCounter < 20) return; - } + else + player.idleCounter = 0; let direction: number = Math.floor(Math.random() * 3); switch (direction) { case 0: