Use a boolean to keep track of whether that flame is there or not. If the flame isn't there, then don't run the collision detection.
Also, in your code:
code: |
if (carX+50 >= check1-3 && carX<= check1+63 || carX+50 >= check2-3 && carX<= check2+63 || carX+50 >= check3-3 && carX<= check3+63)
{
FlameX1 = 145;
FlameX2 = 285;
FlameX3 = 425;
carX = 70;
life--;
draw.repaint();
}
else
{
FlameX1 = 145;
FlameX2 = 285;
FlameX3 = 425;
} |
If you're going change the values of FlameX1-3 in both cases, why not just did it outside the if statement?