import processing.core.*; import java.applet.*; import java.awt.*; import java.awt.image.*; import java.awt.event.*; import java.io.*; import java.net.*; import java.text.*; import java.util.*; import java.util.zip.*; import java.util.regex.*; public class ArrayObjects extends PApplet { /** * Array Objects. * * Demonstrates the syntax for creating an array of custom objects. */ int unit = 40; int num; Module[] mods; public void setup() { size(200, 200); background(176); noStroke(); num = width/unit * width/unit; mods = new Module[num]; for (int i=0; i= size || x <= 0) { xdir *= -1; x = x + (1 * xdir); y = y + (1 * ydir); } if (y >= size || y <= 0) { ydir *= -1; y = y + (1 * ydir); } } // Custom method for drawing the object public void draw() { stroke(second()*4); point(mx+x-1, my+y-1); } } static public void main(String args[]) { PApplet.main(new String[] { "ArrayObjects" }); } }