The entries in this blog correspond to an open, on-line course introduction to the Processing programming language. Questions and comments about individual lessons are encouraged and should be placed in the comments section of the corresponding blog post. I'll try to answer as many questions as I can. The course web page is http://carrot.whitman.edu/IntroProcessing.
Wednesday, July 10, 2013
Day 10
Another example using arrays and the start of object-oriented programming. The video:
It's fine. I would only add that it's good practice to try to limit the scope of all variables when programming. In other words, don't make a variable global unless it's used in several different functions e.g. setup and draw.
Hi, is it a big mistake if I move all global variables and initialize them first, above the setup function? Like this:
ReplyDeleteint numStars =100;
float maxRadius = 2;
int k = 0;
float[] StarfieldX = new float[numStars];
float[] StarfieldY = new float[numStars];
float[] StarfieldR = new float[numStars];
It's fine. I would only add that it's good practice to try to limit the scope of all variables when programming. In other words, don't make a variable global unless it's used in several different functions e.g. setup and draw.
Delete