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)
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() {
//