From 4219704649463a8854b7e96786a49e8037812abf Mon Sep 17 00:00:00 2001 From: dhain Date: Tue, 13 Dec 2022 10:04:16 +0100 Subject: [PATCH] moved obstacle Reset Cheking into a function --- frontend/game.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/game.ts b/frontend/game.ts index acf5a89..b3c5534 100644 --- a/frontend/game.ts +++ b/frontend/game.ts @@ -43,17 +43,21 @@ function draw() { background(backgroundImage) raspberry.draw(); raspberry.update(); - + obstacles.forEach((obstacle) => { obstacle.draw(); obstacle.update(); - if(obstacle.position.x < -obstacleWidth) { - obstacle.resetPosition(true); - } + checkObstacleReset(obstacle); }); } +function checkObstacleReset(obstacle: Obstacle){ + if(obstacle.position.x < -obstacleWidth) { + obstacle.resetPosition(true); + } +} + // // function keyPressed() { //