1powerups = []; 2let powerupSound = new soundOverlapsClass("/ab/audio/powerup"); 3 4class Powerup{ 5 constructor(posX,posY,powerupPic,powerupName){ 6 this.x = posX; 7 this.y = posY; 8 this.pic = powerupPic; 9 this.name = powerupName; 10 this.speed = 2; 11 this.powerupCaught = false; 12 this.useless = false; 13 } 14 15 draw(){ 16 ctx.drawImage(this.pic,this.x,this.y); 17 } 18 19 move(){ 20 let paddleTopEdgeY = PADDLE_Y - PADDLE_GAP; 21 let paddleBottomEdgeY = PADDLE_Y + PADDLE_HEIGHT; 22 let paddleLeftEdgeX = paddle_X; 23 let paddleRightEdgeX = paddleLeftEdgeX + PADDLE_WIDTH; 24 25 26 if(this.y < canvas.height){ 27 28 if( this.y > paddleTopEdgeY && // below the top of paddle 29 this.y < paddleBottomEdgeY && //above the bottom of paddle 30 this.x > paddleLeftEdgeX && // right of the left side of paddle 31 this.x < paddleRightEdgeX) { // left of the left side of paddle 32 33 this.actionForPowerup(); 34 this.powerupCaught = true; 35 this.useless = true; 36 powerupSound.play(); 37 } 38 if(!this.powerupCaught){ 39 this.y = this.y + this.speed; 40 this.draw(); 41 } 42 } 43 else{ 44 this.useless = true; 45 } 46 } 47 48 actionForPowerup(){ 49 50 if(this.name == "freeLife"){ 51 numLives++; 52 } 53 if(this.name == "extraScore"){ 54 score+=1000; 55 } 56 if(this.name == "stickyBall"){ 57 stickyBall = true; 58 59 setTimeout(function(){stickyBall = false;},16000); 60 } 61 if(this.name == "redBall"){ 62 redBall = true; 63 setTimeout(function(){redBall = false;},16000); 64 } 65 if(this.name == "cannon"){ 66 cannon = true; 67 setTimeout(function(){cannon = false;},16000); 68 69 } 70 if(this.name == "multiBall"){ 71 multiBall = true; 72 73 } 74 75 } 76} 77
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.