I'm fairly new to Processing. I'm writing a simple game, and I want a box to move across the screen only when I hold down the arrow buttons. Right now, I can make it so that they move when I press the arrow keys, but the problem is that the shape just continuously moves across the screen.
I would like my shape to move only when I hold down the arrows, and then stop when I release the arrow key.
I'm new to Processing, and I'm trying to create a simple game.
When a shape enters a box, I want the player to earn +5 points. So, I set the parameters:
int points = 0
//scoring
if (x > 225 && x < 255 && y > 225 && y < 125){
points = points +5;
}
However, the way it's set now, it doesn't just add +5 once. Instead, it adds it the entire time the shape is inside the box. So, it adds +5 over and over again. I understand why its happening, but I'm not sure how to fix it. Any help on only running through the script one time and only adding the points once?