Hey y’all I’m tryna make a golf game where when you shoot the ball, the happy face turns into a surprise face and the ball launches from the mouth. I can’t figure out what the heck I’m doing wrong.
boolean launch = true;
if (keyPressed){
if (keyCode == 32){
launch = true;
if (launch);
drawBall();
drawSurprise();
yPos = yPos - ySpeed*2;
} else{
drawPlayer();
xPos = xPos+xSpeed;
}
}
You don’t show too much of your code but I suggest that you move the code section where you draw something into draw() (or loop()) together with if(launch) {...}.
Only the launch = true; stays in the code where you check the key.
Does it work? Do you know why?
Hey and welcome to the forum! Great to have you here!
and yeah I realised it’s cause I never actually set the conditions for the boolean properly, so it was just “boolean = true” and nothing else to back it up and tell it how it should be true XD