/// March 31, 2014 float left= 20, right=left+600, top=50, bottom=top+400; Creature go= new Creature(); Creature ve; void setup() { // setup size( 600, 500); reset(); } void reset() { ve= new Creature(); } void draw() { /// next frame background(100, 100, 255); scene(); moveall(); check(); showall(); messages(); } void scene(){ fill( 150, 150, 150 ); rectMode(CORNERS); rect (left, top, right-50, bottom); } void moveall() { go.move(); ve.move(); } void check () { } void showall() { // Show vreatures go.show(); go.r= 200; go.g= 150; go.b=255; go.rh=255; ve.show(); } void messages() { } class Creature { /// Creature has: /// movement properties (position, speed , etc) /// drawing properyies( width, ht, color, etc.) /// creature does /// move(); /// show() draws it on the screeem /// properties float x=100, y=100, dx=3, dy=2; float w=30, h=50; int r=100, g=255, b=150; //body color int rh=150, gh=50, bh=50; void move() { /// move x, y position if (xright-60) dx= -dx; // Bounce off if (ybottom-30) dy= -dy; dx= dx + random( -1, +1 ); dy= dy + random( -1, +1 ); x= x + dx; y= y + dy; } void show() { // draw on screen fill (r, g, b); rectMode( CENTER ); rect(x, y, w, h); fill(rh, gh, bh); ellipse(x, y-35, 20, 20); } }