Birds or Fish is an easily interactive programming, where a dynamic imaginary creature can be controled with mouse moving. This imaginary creature’s body(with eye), wings, and tails are all made by a repeated shape. When clicking mouse, users can left a creature in a random size and transparency, and it can keep waving wings and shaking tails at a randomspeed.
Birds swim in the sky; fish fly in the sea; how can we tell great difference between them?
Recently I just started to try drawing simple birds(sometimes a phoenix), and my project A’s original idea is Whale Fall which need to draw some fish. When thinking about this project, I randomly drew some sketches and found the curves of fish and birds have great smilarity and beauty.
Demo/Visual Documentation:
Development and Technical Implementation
Describe what values were stored in the array(s) and how you utilized them. Share your experience while using the array(s).
I defined 5 arrays as abcde. a[] and b[] are used to record the position of the clicked mouse’s position, and later place all the creatures left by users’ clicked mouse in for loops. c[], d[], and e[] are used to randomly set values that can maintain in the following loops.
one problem here is that the “deg” directly inputs “d[]” is a fixed value since placed creatures are expected to waving wings and tails on their position. Therefore, the third element (drawCreature(0,0,deg*d[i],e[i])) here must depend on the changing “deg”.
Also, the translate in loops keeps updating, which makes the coding easiler to both design and read.
Besides, they are better to surround each element, no matter outside the calling of UDF or inside the UDF. Because the calling will be continually repeated with loops running, and it will be more convenient to add some random update.
What is the effectiveness of User-Defined Functions?
UDF can be called repeatedly and sometimes can have some changes with interesting values. When a certain stuff is frequently needed, creating and calling a UDF can make codes easier, clear, and readable.
What parameters did you added to your functions? How were they manipulate the effects of the functions?
I added arrays to record the position of previous creatures and to set random parameters for scale and transparency, in order to make interaction with mousePressed that left a random creature on the screen everytime the user pressed the mouse.