How to program a tie score in a Pong Game ?
in
Programming Questions
•
4 months ago
Im doing a Pong Game, where I want the score to be like a Tennis Game.
I already manage to make the code where the first and second score are worth 15 points and the third score is worth 10 points like in Tennis.
But now I want to make the situation where there is a tie when they reach the 40 points.
As in tennis i want that when they are tied at forty, one of them has to do 2 consecutive points to win the game. If one of them makes a point and then the other makes also one point, the they stay playing until one of them scores 2 consecutive points.
This is what i managed to do so far, the score until 40;
I already manage to make the code where the first and second score are worth 15 points and the third score is worth 10 points like in Tennis.
But now I want to make the situation where there is a tie when they reach the 40 points.
As in tennis i want that when they are tied at forty, one of them has to do 2 consecutive points to win the game. If one of them makes a point and then the other makes also one point, the they stay playing until one of them scores 2 consecutive points.
This is what i managed to do so far, the score until 40;
if (ballPosX < 0)
{
if (PointsP2==0){
PointsP2 +=15;
}
else if(PointsP2==15){
PointsP2+=15;
}
else if(PointsP2==30){
PointsP2+=10;
}
ballPosX = 500;
ballPosY = 250;
ballSpeedX *= -1;
}
if (ballPosX > 1000) {
if (PointsP1==0){
PointsP1 +=15;
}
else if(PointsP1==15){
PointsP1+=15;
}
else if(PointsP1==30){
PointsP1+=10;
}
ballPosX = 500;
ballPosY = 250;
ballSpeedX *= -1;
}
}
}
1