dondogo
YaBB Newbies
Offline
Posts: 5
Re: Constructor error 'undefined'
Reply #3 - Feb 12th , 2009, 6:08am
This is the original program. I'm trying to clean it up using classes and such for the fish and its movements. //fish float fx = 250; float fy = 250; float dx; float dy; float b; void setup () { size (700,700); smooth (); } void draw () { noStroke(); background (0,126,246); b=random (2,15); //draw fish //backeye fill (0); ellipse (fx+20,fy-20,20,25); //draw fins fill(220,105,12); //left fin triangle (fx-3,fy+30,fx+5,fy+68,fx+21,fy+28); //backfin triangle (fx-75,fy+14,fx-95,fy+35,fx-7,fy+12); //body fill (240,150,60); ellipse (fx,fy,60,75); //right fin fill(240,125,12); triangle (fx-20,fy+25,fx-10,fy+30,fx-35,fy+65); //draw fish lips fill(230,25,25); ellipse (fx+33,fy-3,12,30); fill(130,25,25); ellipse (fx+35,fy-3,6,15); //draw eye shadow fill (170,110,49); ellipse(fx+8,fy-13,20,25); //draw front eye fill(0); ellipse (fx+10,fy-15,20,25); //draw eye spots fill(255); //front ellipse (fx+10,fy-25,6,8); //back ellipse (fx+23,fy-30,4,6); dx = fx-mouseX; dy = fy-mouseY; //fx = fx+(random(-5,5)); //fy = fy+(random(-5,5)); if (keyPressed == false) { //how close if (abs(dx) < 60) { fx = fx+(dx/2); //bubbles stroke (255); fill (0,0,0,0); ellipse (random (fx+40,fx+60),random (fy-40,fy-60),b,b); ellipse (random (fx+65,fx+85),random (fy-65,fy-85),b,b); } //how distant if (abs(dx) > 300) { fx = fx-(dx/2); } //for verticle //how close if (abs(dy) < 60) { fy = fy+(dy/2); //bubbles stroke (255); fill (0,0,0,0); ellipse (random (fx+40,fx+60),random (fy-40,fy-60),b,b); ellipse (random (fx+65,fx+85),random (fy-65,fy-85),b,b); } if (abs(dy) > 300) { fy = fy-(dy/2); } } }