I am trying to write a program that causes the circle to go in one direction but when I press the letter ‘a’ on the keyboard it will go the opposite direction. Additionally, if the circle reaches a boundary it will go the opposite direction. My issue is when I press the letter ‘a’ on my keyboard it only changes direction sometimes. I was trying to accomplish this by using an if statement. I have attached my code below. Any help would be greatly appreciated,
Thank you for your help! The code is now working after implementing your suggestions. The biggest issue seems to have been that there was not a keyPressed () function.