Genuinely don't know where to go from here (golf game)

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;
}
  }

This should initially be false I guess.

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!

Regards,

Chrisir

Y’all can look here for resources (tutorials, examples, references, books, etc.):

And Google search for:
image

:)

Thank you!

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

1 Like

yeah that’s what I’ve been using

1 Like