moved obstacle Reset Cheking into a function

This commit is contained in:
dhain 2022-12-13 10:04:16 +01:00
parent d0724e668a
commit 4219704649

View file

@ -43,17 +43,21 @@ function draw() {
background(backgroundImage) background(backgroundImage)
raspberry.draw(); raspberry.draw();
raspberry.update(); raspberry.update();
obstacles.forEach((obstacle) => { obstacles.forEach((obstacle) => {
obstacle.draw(); obstacle.draw();
obstacle.update(); obstacle.update();
if(obstacle.position.x < -obstacleWidth) { checkObstacleReset(obstacle);
obstacle.resetPosition(true);
}
}); });
} }
function checkObstacleReset(obstacle: Obstacle){
if(obstacle.position.x < -obstacleWidth) {
obstacle.resetPosition(true);
}
}
// //
// function keyPressed() { // function keyPressed() {
// //