Computational Media

Class 4: Re-code the Fishes

For this week, I recode my old fishes code, using objects and functions.

First of all, I simplified the codes I have done before, I  used more variables to make the codes a lot simpler, especially got rid of the extra code when the fishes are turning.

Instead of playing around with functions, I am more fond of the objects, I made the original codes into two objects, the big fish and the small fish. I tried to replicate more small fishes in different sizes and colors, but I couldn’t figure it out how to achieve that in the objects, I don’t know the syntex for that yet. So as for this time, I would use the functions instead, it’s also a nice practice.

Here is the refined version of my codes. I did find it require more efforts when the x and y positions were changing all the time, how to set up the functions where the starter point is different?

However, I do have two questions;

  1. The small fishes made by function() seems to have the same speed even though they have different parameters.
  2. How to use return() in my case? Is return() means simply to set the number back to setup()?? Or set the number back to it’s function’s start? [that is the sense I get after watching Daniel’s videos]

Leave a Reply

Your email address will not be published. Required fields are marked *