PDA

View Full Version : Falling snow tut, modified..



RussianBeer
August 9th, 2003, 01:24 PM
Okay, I remeber making this work at one point... but I forgot..


There is a Snowfalling tutorial here, I messed around with the code to make it instead of fall rise, the only proble is, that it rises from on point, and dosent appear random at the bottom, but from a single spot.. anyway here is my AS.

onClipEvent (load) {
//specifies the size of the movie stage
movieWidth = 500;
movieHeight = 200;

//variables that will modify the falling snow
k = 1+Math.random()*2;
i = -Math.PI+Math.random()*Math.PI;

//giving each snowflake unique characteristics
this._xscale = this._yscale=50+Math.random()*100;
this._alpha = 10+Math.random()*50;
this._x = -10+Math.random()*movieWidth;
this._y = -10+Math.random()*movieHeight;
}
onClipEvent (enterFrame) {
//putting it all together
rad += (k/180)*Math.PI;
this._x -= Math.cos(rad);
this._y += i;
if (this._y>=movieHeight) {
this._y = -5;
}
if ((this._y>=movieWidth) || (this._y<=33)) {
this._y = +200;
this._x = +200+Math.random()*movieWidht;
}
}

Johnny64
August 9th, 2003, 02:35 PM
Hoi

i got this to work ;)


onClipEvent (load) {
//specifies the size of the movie stage
movieWidth = 200;
movieHeight = 200;
//variables that will modify the falling snow
k = Math.random()*2;
i = Math.PI+Math.random()*Math.PI;
//giving each snowflake unique characteristics
this._xscale = this._yscale=50+Math.random()*100;
this._alpha = 10+Math.random()*50;
this._x = Math.random()*movieWidth;
this._y = movieHeight;
}
onClipEvent (enterFrame) {
//putting it all together
rad += (k/180)*Math.PI;
this._x += Math.cos(rad);
this._y -= i;
if (this._y<=0 || this._x>=movieWidth || this._x<=0) {
this._y = movieHeight;
this._x = Math.random()*movieWidth;
}
}

RussianBeer
August 9th, 2003, 02:42 PM
gracias comarade!