pong: let bot idle last longer
This commit is contained in:
parent
51ec729979
commit
3aaa6740f4
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user