Design a class called "Spinny". This class creates a rectangle that rotates in place, so a Spinner must know its own coordinates and angle of rotation. It should also have a varying speed and the ability to "pause" the spinning. In your main program, create several Spinners at random locations, and then pause or unpause them if they are clicked on, like in the example below. Hint: to figure out if you clicked in the shape, use an approximation (distance from center) so you don't have to figure out the rotation. If you want to be precise, see the screenX() and screenY() functions for a way to map the coordinates exactly.
We'll work on this during next class, but you should at least have the variables, a constructor, and some attempt at the functions for the class.
We're going to start learning about physics this week, and we'll do so by progressively adding features to a program to build it up slowly. Work through the assignments in order as best you can, and we'll answer questions during class.
Make a class-based program that has one class, called "Ball" in it. A ball should know where it is on the screen, how big it is, and what color it is. If you click on a ball, it should alternate its color between red, green, and blue. Balls do not move on their own, nor can they be dragged. See the example below:
The version above should work for any number of Ball objects in an array, so you should be able to create an arbitrary number just by changing a single parameter in your program (the size of the array). You should randomize the location of the Ball objects, either in the constructor or by passing random values to the constructor.
Add velocities to the balls so they move on their own, and change color whenever they hit a side. If you need some hints, remember that the objects tutorial created a Car that had velocity and wrapped around the screen. It should look something like this:
If you get through everything above and still have time, add gravity to the velocities (recall that acceleration is just a change in velocity over time...). For extra features, allow the user to click on the screen to "pop" everything back into the air, and (if you can!) allow collisions between objects. Don't worry if you can't get to all of this; we'll talk about it in class.