diff --git a/src/pong.ts b/src/pong.ts index 89ed43a..d46b19a 100644 --- a/src/pong.ts +++ b/src/pong.ts @@ -45,6 +45,7 @@ class Paddle { isLeft: boolean; score: number; dy: number; + idleCounter: number; constructor(_geometry: Box, _isLeft: boolean) { this.geometry = _geometry; @@ -53,6 +54,7 @@ class Paddle { this.isBot = true; this.score = 0; this.dy = 0; + this.idleCounter = 0; } scored() { @@ -254,6 +256,10 @@ class PongCore { // Randomly move the bot paddle when ball not towards it botIdle(player: Paddle) { + if (player.idleCounter < 10) { + player.idleCounter++; + return; + } let direction: number = Math.floor(Math.random() * 3); switch (direction) { case 0: