class Tornado{
Vector3D loc;
Vector3D vel;
Vector3D acc;
//another constructor just in case i need
Tornado(Vector3D a, Vector3D v, Vector3D l) {
acc = a.copy();
vel = v.copy();
loc = l.copy();
}
//but mostly i'd use this constructor
//get location from the sine wave
Tornado(Vector3D l) {
loc = l.copy();
}
void calcTornado() {
float theta2 = loc.y;
// println("calculating Tornado rendering location");
loc.x = loc.x + sin(theta2+frameCount)*((height -loc.y)/5);
renderTornado();
theta2 += 0.01;
}
void renderTornado () {
fill(255, 50);
if ((loc.y + 1)%13 ==1 || (loc.y + 1)%9 ==3 || (loc.y + 1)%11 ==1) {
ellipse(loc.x, loc.y, 3, 2);
}
fill(255, 30);
if ( (loc.y + 1)%11 ==2 || (loc.y + 1)%5 ==3 || (loc.y + 1)%19 ==3) {
ellipse(loc.x, loc.y, 3, 4);
}
fill(255, 20);
if ( (loc.y + 1)%19 ==4 || (loc.y + 1)%6 ==3 || (loc.y + 1)%13 ==3) {
ellipse(loc.x, loc.y, 5, 4);
}
// println("tornado rendering");
}
}
Show pagesource
Old revisions
Backlinks
Index
Recent changes
Login
nature-of-code/tornado.java.txt · Last modified: 2009/04/26 01:30 (external edit) |