Does anyone know what’s wrong with the following code, it’s not working for me. It’s for a pong game im making. Only the last part isn’t working but the rest is ok. I want the ball to bounce off in a different direction if it hits the egdes than it would if it hits the middle.
game.checkPaddleCollisions = function() {
if (this.ball.tempx<THIS.LEFTPADDLE.X+THIS.LEFTPADDLE.WIDTH && this.ball.tempx+this.ball.radius>this.leftPaddle.x && this.ball.tempy+this.ball.radius>this.leftPaddle.y && this.ball.tempy<THIS.LEFTPADDLE.Y+THIS.LEFTPADDLE.HEIGHT) {< p>
//left paddle collision detection
this.ball.tempx = this.leftPaddle.x+this.leftPaddle.width;
this.ball.xmov *= -1;
this.ball.xmov += .15;
soundIdentifier.start();
if (38<THIS.BALL.TEMPY)< p> this.ball.ymov *= 1.1;
else if (38>this.ball.tempy)
this.ball.ymov *= .1;
}
if (this.ball.tempx<THIS.RIGHTPADDLE.X+THIS.RIGHTPADDLE.WIDTH && this.ball.tempx+this.ball.radius>this.rightPaddle.x && this.ball.tempy+this.ball.radius>this.rightPaddle.y && this.ball.tempy<THIS.RIGHTPADDLE.Y+THIS.RIGHTPADDLE.HEIGHT) {< p>
//right paddle collision detection
this.ball.tempx = this.rightPaddle.x-this.ball.radius;
this.ball.xmov *= -1;
this.ball.xmov -= .15;
soundIdentifier.start();
}
};
I have attached my fla. if anybody wants to tinker with it to make it work. Its in MX 2004 Professional.