In CSC207 (Software Design), we are picking up Java through the development of an Android App. This first project is a simple one – clean up a bunch of spaghetti code and add features to the base to make a little digital Fish Tank. Here’s my take on it…
The project was mostly a study in inheritance. A single parent Class for all onscreen items allowed for easy frame updates and movement. A Class for fish allowed behaviors to be extended by different types of fish. I also created an Interface for destructible items (bubbles, poop, and food), but I think I need to learn more to make the most out of Interfaces.
Given the bones of the animation, I decided to add an element that I thought would be a challenge – a little Fish Food (red squirmy things). These Foods spawned randomly, and if a fish swam close enough to detect it, the fish would beeline towards it. Having consumed a Food, they would grow (longer) until they reached their stomach’s fill. This would be offset by the occasional random poop (ugly yellow streak), which would reduce the stomach’s content and restore its appetite.
I had made the food swim randomly around the tank, but since the fish only moved 1 unit per refresh, it was tough to catch the squirmy food – a bit too chaotic. A little less motion made the fish tank a little more zen.
So far, Java has been a bit less intuitive than Python (keep forgetting those ;’s), but the payoff in the little Android app is rewarding!
I just wish I could figure out how to remove the title/menu bars.