//Vehicle 2: // something isn't working properly, but they're still moving like little insect things... // class Vehicle contains 2 objects of class Motor and 2 of class Sensor, coupled // the mouse is the nice smell in the world int worldsize = 500; int maxv = 8; float friction = 0.90; float sniffrange = 30; Vehicle[] vehicles = new Vehicle[maxv]; void setup() { size(worldsize,worldsize); stroke(200,200,200); rectMode(CENTER_DIAMETER); for (int i=0;i 0 && vely*(mouseY-y) > 0) { m1.speed += s1.sense; m2.speed += s2.sense; } // rotation due to separation of motors direction += (m1.speed-m2.speed)*(m1.speed+m2.speed)*0.1; // small random pertubations direction *= 1 + ((random(100)-50)/6000); render(); } void render() { push(); translate(x,y); rotate(direction); stroke(100); rect(0,0,6,2); m1.render(); m2.render(); s1.render(); s2.render(); pop(); } }