Need help with processing ball game

Create a program that displays a window, 300 by 400, randomly placing a red ball
(circle) of diameter 20 randomly somewhere in that space. When any key is pressed,
the ball will bounce back and forth horizontally on the screen (moving in increments
of 5), never disappearing or leaving a trail. Another key press will freeze the ball in
place, another will resume the horizontal movement, and so on. (Meaning any key
“toggles” movement on and off.)

-The ball moves (and bounces) vertically as well as horizontally. Ensure it is always
completely visible (not half off the screen if you stop it).
-If the mouse is moved to the middle of the circle while it is frozen, this also starts
the circle moving (instead of a key press). Note that pressing a key should still toggle
movement on/off (not have no effect).

-The ball slows down somewhat with every bounce off a wall (so no longer always
uses increments of 5 after hitting), but it never completely stops.
-If the mouse is used to start the circle movement (ie- user did not hit a key), the
circle turns green, and resumes maximum movement (by 5s). Hitting a key will both
turn the ball back to red, and toggle movement on/off as above.

Hello and welcome to the forum.

What kind of help you need? Do you have code that you have problems with? Or is there a part you find difficult and we could help you with?

Processing reference https://processing.org/reference/ is a good source to check available functions and how they work. Examples in references give an idea how they can be used and even give a bit of code you can use in your own programs.

One of the benefits of processing is that you can build your programs in small steps. Ball game is described so that you can follow it and add features one by one.

2 Likes