pong: reset counter on idle and increase idle length
This commit is contained in:
parent
3aaa6740f4
commit
225e5e8422
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user