/** * Schnee: * Design by Steve Gallay, steve@gallay.li * Created 11 Juni 2007 * */ //_________________________________________________________________________________________ // // VARIABLES // Schnee[] flocons = new Schnee[20000]; int nelement=0; float winkel=0; PImage fond; //_________________________________________________________________________________________ // // SETUP // void setup() { //size(screen.width,screen.height); size(800,600); frameRate(10); smooth(); background(10); fond = loadImage("Neige1.jpg"); } //_________________________________________________________________________________________ // // DRAW // void draw() { image(fond,0,0,width,height); // neue flocons for(int i=0; i<10; i=i+1){ flocons[nelement] = new Schnee(int(random(width)),0,0,0,random(5),random(100)); nelement +=1; } // print for(int i=0; i (2 / 3 * height)){; flocons[i].bodenWind(width/4,height); } flocons[i].newton(); flocons[i].druck(); } winkel += 0.005; } //_________________________________________________________________________________________ // // Schnee - CLASS // class Schnee { int X_ref; int Y_ref; float delta_X; float delta_Y; float radius; float enfernung; Schnee(int X_refInput,int Y_refInput,float delta_XInput,float delta_YInput,float radiusInput, float enfernungInput) { X_ref = X_refInput; Y_ref = Y_refInput; delta_X = delta_XInput; delta_Y = delta_YInput; radius = radiusInput; enfernung = enfernungInput; // 0-100 } void druck() { noStroke(); fill(255, 255, 255,(255 - enfernung)); ellipse(X_ref,Y_ref,radius,radius); } void newton() { if (Y_ref < height){ Y_ref += int((enfernung/100) * 5) + 5 + delta_Y; X_ref += delta_X; } } void wind(float x_wind, float y_wind) { delta_Y = y_wind; delta_X = x_wind; } void bodenWind(int x_zentrum, int y_zentrum) { float vUnit = sqrt(sq(X_ref - x_zentrum) + sq(Y_ref - x_zentrum)); delta_X += (X_ref - x_zentrum) / vUnit * 4 ; delta_Y += -(Y_ref - x_zentrum) / vUnit * 4; } int Flocon_hoehe(){ return(Y_ref); } }