ArrayList fische; ArrayList markers; float msize = 160; float msize2 = 160; float r = 100; // häufigkeit der teilung int strokeFisch = 10; int strokeMarker = 5; int tot = 0; void setup() { background(40); size(1200,400); fische = new ArrayList(); fische.add(new Fisch(0,height/2,50,100,50,2.5,false)); markers = new ArrayList(); stroke(255,100); frameRate(25); smooth(); } void restart() { markers.clear(); fische.clear(); tot = 0; fische.add(new Fisch(0,height/2,50,100,50,2.5,false)); } // #### MARKER KLASSE +++ class Marker { float t_mx; float t_my; float t_st; int t_type; boolean t_moment; Marker(float mx, float my, float st, int type) { t_mx = mx; t_my = my; t_st = st; t_type = type; } void drawMarker() { if(this.t_type == 1) { noStroke(); if(this.t_st<0.8) { fill(0,250,250,(1-this.t_st)*255); noStroke(); this.t_st = this.t_st + 0.05; ellipse(this.t_mx,this.t_my,msize*this.t_st,msize*this.t_st); } } if(this.t_type == 0) { noStroke(); if(this.t_st<1) { stroke(200,200,200,(1-this.t_st)/10*255); noFill(); this.t_st = this.t_st + 0.05; this.t_my = this.t_my - 5; strokeWeight(strokeMarker); ellipse(this.t_mx,this.t_my,msize2*this.t_st,msize2*this.t_st); } } noFill(); } } class Fisch { float t_startx; float t_starty; float t_endx; float t_endy; float t_l; float t_y; float t_speed; boolean t_moment; Fisch(float startx, float starty, float endx, float endy, float l, float speed, boolean moment) { t_startx = startx; t_starty = starty; t_endx = endx; t_endy = endy; t_l = l; t_speed = speed; t_moment = false; } void drawFisch() { stroke(255,100); strokeWeight(strokeFisch); if(this.t_l > 1) { this.t_endx = this.t_startx + this.t_l; if(this.t_y > 3 || this.t_y < -3 || this.t_starty < 10 || this.t_starty > height-10) { if(this.t_y > 3 || this.t_starty > height-10) { this.t_y = this.t_y - 1; } if(this.t_y < -3 || this.t_starty < 10) { this.t_y = this.t_y + 1; } } else { this.t_y = this.t_y + random(-1,1); } this.t_endy = this.t_starty + this.t_y; line(this.t_startx,this.t_starty,this.t_endx,this.t_endy); this.t_startx = this.t_startx + this.t_speed; this.t_starty = this.t_endy; this.t_l = this.t_l-0.2; /* TEILUNG */ int manchmal = round(random(0,r)); if(manchmal == 2) { fische.add(new Fisch(this.t_startx,this.t_starty,this.t_endx,this.t_endy,50,random(1,4),false)); markers.add(new Marker(this.t_endx,this.t_endy,0.1,1)); } if(this.t_startx > width+100) { restart(); } } else { if(!this.t_moment) { markers.add(new Marker(this.t_endx,this.t_endy,0.1,0)); tot++; this.t_moment = true; } } } } void draw() { background(40); for(int j = 0; j<=fische.size()-1; j++) { Fisch fisch = (Fisch) fische.get(j); fisch.drawFisch(); } for(int jj = 0; jj<=markers.size()-1; jj++) { Marker marker = (Marker) markers.get(jj); marker.drawMarker(); } println("fische.size(): "); println(fische.size()); println("tot: "); println(tot); if(fische.size()==tot && tot != 0) { restart(); } }