Im doing a Pong Game, and I want that when the ball hits the block/paddle to make a sound, but I only manage to make the sound play once.
It hits the block the first time and it makes the sound and then if hits the block again it doesnt do anything.
I tried to do "BallSound.loop();", but then the sound repeats even when the ball doesnt hit the block.
I'd aprecciate any help, thank you.
Here is the code:
It hits the block the first time and it makes the sound and then if hits the block again it doesnt do anything.
I tried to do "BallSound.loop();", but then the sound repeats even when the ball doesnt hit the block.
I'd aprecciate any help, thank you.
Here is the code:
import ddf.minim.*;
Minim minim;
AudioPlayer BallSound;
minim=new Minim(this);
BallSound=minim.loadFile("TennisBallSound.wav");
:
:
:
:
:
:
:
void loop()
{
.
:
:
:
:
if (ballPosX > Pos1X && ballPosX < Pos1X + blockWidth && ballPosY > Pos1Y && ballPosY < Pos1Y + blockHeight)
{
ballSpeedX *= -1;
BallSound.play();
}
if (ballPosX > Pos2X && ballPosX < Pos2X + blockWidth && ballPosY > Pos2Y && ballPosY < Pos2Y + blockHeight)
{
ballSpeedX *= -1;
BallSound.play();
}
:
:
:
: