moved obstacle Reset Cheking into a function
This commit is contained in:
parent
d0724e668a
commit
4219704649
1 changed files with 8 additions and 4 deletions
|
|
@ -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() {
|
||||
//
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue