More Cartwheeling stars

More Cartwheeling stars

I decided the only thing better than one cartwheeling star, is ten cartwheeling stars. I re-factored my code from last week and built a Star class with its own properties and functions. In the draw function, I add a new star in every x iterations which I then add to an ArrayList. At the top of the draw function I iterate through this ArrayList and call the star’s cartwheel function on each star. I also wrote a mousePressed function which iterates over all Star objects and checks if the mouse is pressing on a star by calling the star’s overStar function. If the mouse is over the star, the star’s turn function is called which changes the direction of the cartwheeling star.

 

And here are all the (mostly happy) stars!

Screenshot 2014-09-23 11.32.26