PDA

View Full Version : Snow



Sammo
January 14th, 2006, 06:00 PM
A modification of my snow 3.0 to be under 25 lines. I've used a function originally created by Senocular but modified by me (drawCircle), I hope this is ok.


function drawCircle(x, y, d) {
a = _root.createEmptyMovieClip("snow",1000); //1
a.lineStyle(1, 0xffffff, 100); //2
a.beginFill(0xffffff, 100); //3
a.moveTo(x+d/2, y); //4
a.curveTo(x+d/2, y+(d/2*(Math.SQRT2-1)), x+(d/2*Math.SQRT2/2), y+(d/2*Math.SQRT2/2)); //5
a.curveTo(x+(d/2*(Math.SQRT2-1)), y+d/2, x, y+d/2); //6
a.curveTo(x-(d/2*(Math.SQRT2-1)), y+d/2, x-(d/2*Math.SQRT2/2), y+(d/2*Math.SQRT2/2)); //7
a.curveTo(x-d/2, y+(d/2*(Math.SQRT2-1)), x-d/2, y); //8
a.curveTo(x-d/2, y-(d/2*(Math.SQRT2-1)), x-(d/2*Math.SQRT2/2), y-(d/2*Math.SQRT2/2)); //9
a.curveTo(x-(d/2*(Math.SQRT2-1)), y-d/2, x, y-d / 2); //10
a.curveTo(x+(d/2*(Math.SQRT2-1)), y-d/2, x+(d/2*Math.SQRT2/2), y-(d/2*Math.SQRT2/2)); //11
a.curveTo(x+d/2, y-(d/2*(Math.SQRT2-1)), x+d/2, y); //12
}
drawCircle(-10,-10,10); //13
for (i=0;i<75;i++) { //14
t = snow.duplicateMovieClip("snow"+i,i); //15
t._x = -(Stage.width/2)+Math.random()*(1.5*Stage.width); //16
t._y = -(Stage.height/2)+Math.random()*(1.5*Stage.height); //17
t._xscale = t._yscale = 10+Math.random()*40; //18
t.k = 1+Math.random()*2, t.wind = -1.5+Math.random()*(1.4*3); //19
t.onEnterFrame = mover; //20
}
function mover() {
this._y += this.k, this._x += this.wind; //21
(this._y > Stage.height+10) ? this._y = -20 : null; //22
if (this._x > Stage.width+20 || this._x < -20) { //23
this._x = -(Stage.width/2)+Math.random()*(1.5*Stage.width); //24
this._y = -20; //25
}
}

Bang on 25 lines... *phew*

freeskier89
January 14th, 2006, 06:12 PM
If statements and for loops count towards the 25 lines, so you have 27 lines now. *cough* use basic trig to draw the circles and you will be well under 25 lines.

Sammo
January 14th, 2006, 06:16 PM
If statements and for loops count towards the 25 lines, so you have 27 lines now. *cough* use basic trig to draw the circles and you will be well under 25 lines.
They do? Kirupa's guildlines says anything that end's in a semi-colon. Bummer.

Ps, PMed ya.

kirupa
January 14th, 2006, 06:28 PM
Yeah, loops and if statements do count towards your line count total. I have amended the guidelines to mention that :nat:

kdd
January 14th, 2006, 06:44 PM
that's cool. (i don't know how many lines there are, i haven't counted them.) sorry to say this, but according to physics, global wind that collides with each snow particle would result in same direction; unless otherwise each particle is in different system where there is diff. winds. :blush: but, it's cool. :P

bombsledder
January 14th, 2006, 08:14 PM
dont they have a tutorial on making snow lol?

Sammo
January 14th, 2006, 08:16 PM
each particle's in a different system :D

and it's now 25 lines, not 27.

Seb Hughes
January 14th, 2006, 08:35 PM
nice effect :D

Sammo
January 15th, 2006, 05:31 AM
dont they have a tutorial on making snow lol?
Yes, it's my tutorial! :D

hybrid101
January 15th, 2006, 05:59 AM
nice! i love this effect!