Moved the balls behind the bar

This commit is contained in:
jdg committed 2021-11-13 00:44:20 +01:00
1 parent ae92c56957
commit b682ad199c
2 files changed
+2 -1

No files matched your search

+1
View File
@@ -55,6 +55,7 @@ class Ball {
this.moving = false;
return false;
}
if (this.y > this.bar.y ) return true; // Ball is lost, don't check anything else
if ( (this.y + this.size) > this.bar.y && this.x > this.bar.x && this.x < (this.bar.x + this.bar.w) ) {
// Down (Bar)
+1 -1
View File
@@ -62,12 +62,12 @@ function init() {
if(gstate==2) {
gameOver.update();
} else {
bar.update();
balls = balls.filter(ball => ball.update());
if (balls.length==0) {
if ( lives.lost() ) gstate=2;
else balls.push(new Ball(ctx, bar));
}
bar.update();
}
score.update();
lives.update();