EDIT: Just so people are aware I am using the excellent book Learning processing written by Daniel Shiffman, which I forgot to mention since this article is part of a series of article about my self taught Processing training. END OF EDIT ~
This is my second project for processing fish pond. It’s not a game or anything, more an interactive pond where you control a fish that grows every time it eats food.
It’s mainly to practice object oriented programming with arrays and arrays of objects. With some random rain drop, I also practice with the rotate and translate function. Understanding that when using translate, your 0,0 coordinate becomes that translate. In order to draw a X and rotate it from it’s centre, you need to use negative value.
int r = 0;
r = r++;
Would create a X shape that rotate from it’s centre. The radians is used in order not to have to ply around with PI which is the default for the rotate function. I also used the % modulo to try to add some visual to the rotating X. The modulo is what remain after dividing a number by another number. So 10 % 3 is 1, and 9 % 3 is 0. It’s an interesting function to be able to create pulsing images.
In my last project blood in order to calculate if the mouse was on top of the first drop of blood I used a simple if mouseX to check if the mouse was over the drop. This time I used the dist function that calculate the distance between object. That created a cleaner code to verify if the fish was near enough of the food.
There is no goal to the game, simply to eat the food and grow the fish 😉 I guess my next project will combine a goal as well as an interactive part… stay tune!