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)
|
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() {
|
||||||
//
|
//
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue