Hello, I’m trying to code a ball that, when the program is executed, moves side to side. When a key is pressed (and held down), a power bar appears displaying how much power the ball is going to shoot with when the key is released.
So far i’ve got the ball moving side to side and the power bar functioning, i’m only struggling with the code that shoots the ball up.
i have written a function for the ball moving up which i know works (i have tested the code on its own), but when i call the function it doesn’t work.
this is drawing of your ball, and where its movement is set by adding speedEllipse each frame;
so now the question (answer) is , when keyReleased occur how do you manipulate this speedEllipse value?
if you do println(speedEllipse); at the end of keyReleased, does it change as expected?
for the other code you have in keyRelease: according to keyRelease reference,
" The keyReleased() function is called once every time a key is released."
what do you expect from this?
I am struggling to find a way to identify when a key has been released, resulting with me not being able to run the code that moves the ball vertical.
I also added the line println(speedEllipse); and saw that the speed value isn’t changing from 3. Since the code that changes the speed is also triggered after a key has been released, this is also linked to my first problem.
I was wondering if you could provide more guidance on how i can detect when a key has been released and how to run this section of the code: