Moved the balls behind the bar
This commit is contained in:
		
							
								
								
									
										1
									
								
								Ball.js
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								Ball.js
									
									
									
									
									
								
							@ -55,6 +55,7 @@ class Ball {
 | 
				
			|||||||
                this.moving = false;
 | 
					                this.moving = false;
 | 
				
			||||||
                return 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) ) {
 | 
					            if ( (this.y + this.size) > this.bar.y && this.x > this.bar.x && this.x < (this.bar.x + this.bar.w) ) {
 | 
				
			||||||
                // Down (Bar)
 | 
					                // Down (Bar)
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								index.js
									
									
									
									
									
								
							@ -62,12 +62,12 @@ function init() {
 | 
				
			|||||||
                if(gstate==2) {
 | 
					                if(gstate==2) {
 | 
				
			||||||
                    gameOver.update();
 | 
					                    gameOver.update();
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    bar.update();
 | 
					 | 
				
			||||||
                    balls = balls.filter(ball => ball.update());
 | 
					                    balls = balls.filter(ball => ball.update());
 | 
				
			||||||
                    if (balls.length==0) {
 | 
					                    if (balls.length==0) {
 | 
				
			||||||
                        if ( lives.lost() ) gstate=2;
 | 
					                        if ( lives.lost() ) gstate=2;
 | 
				
			||||||
                        else balls.push(new Ball(ctx, bar));
 | 
					                        else balls.push(new Ball(ctx, bar));
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					                    bar.update();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                score.update();
 | 
					                score.update();
 | 
				
			||||||
                lives.update();
 | 
					                lives.update();
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user