Snowing Up

Started by Hnilmik, March 7, 2011 10:20 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Hnilmik

Being the lazy git I am, I tried to find a simpler way to make "floating glowy thingies" than the initial methods I had in mind (read: stupid-looking tweens).

This method was the closest to pulling off the results I want. I figured from here, some tweaking could be done if it was actionscript.

http://www.youtube.com/watch?v=Qi5YJ-RHHFA

Thing is, I wish I knew there was a way to make it "snow up" or in some other direction instead. I don't know crap about coding/programming.

Here's the code:
init = function () {

    width = 550;
    height = 400;
    max_snowsize = 5;
    snowflakes = 100;

    for (i=0; i<snowflakes; i++) {

    t = attachMovie("snow", "snow"+i, i);
    t._alpha = 20+Math.random()*60;
    t._x = -(width/2)+Math.random()*(1.5*width);
    t._y = -(height/2)+Math.random()*(1.5*height);
    t._xscale = t._yscale=50+Math.random()*(max_snowsize*10);
    t.k = 1+Math.random()*2;
    t.wind = -1.5+Math.random()*(1.4*3);
    t.onEnterFrame = mover;

    }

    };
    mover = function() {

    this._y += this.k;
    this._x += this.wind;
    if (this._y>height+10) {

    this._y = -20;

    }
    if (this._x>width+20) {

    this._x = -(width/2)+Math.random()*(1.5*width);
    this._y = -20;

    } else if (this._x<-20) {

    this._x = -(width/2)+Math.random()*(1.5*width);
    this._y = -20;

    }

    }
    init();


Thanks in advance~

rtil

#1
this will make the snow go up. i also toned down the "wind" a little
init = function () {
    width = 720;
    height = 405;
    max_snowsize = 5;
    snowflakes = 100;
    for (i = 0; i < snowflakes; i++) {
        t = attachMovie("snow", "snow" + i, i);
        t._alpha = 20 + Math.random() * 60;
        t._x = -(width / 2) + Math.random() * (1.5 * width);
        t._y = -(height / 2) + Math.random() * (1.5 * height);
        t._xscale = t._yscale = 50 + Math.random() * (max_snowsize * 10);
        t.k = 1 + Math.random() * 2;
        t.wind = 0.9 * (Math.random() / 2);
        t.onEnterFrame = mover;
    }
};

mover = function () {
    this._y -= this.k;
    this._x += this.wind;
    
    if (this._y < -20) {
        this._y = height+10;
    }
    if (this._x > width + 20) {
        this._x = -(width / 2) + Math.random() * (1.5 * width);
        this._y = height;
    } else if (this._x < -20) {
        this._x = -(width / 2) + Math.random() * (1.5 * width);
        this._y = height;
    }
};

init();

Hnilmik

Thanks~!!

Is there a way to get something like a continuous stream instead of a wave and lull then the stream?

billy

lol rtil remember that star syndicate christmas collab you put together where someone had actionscript snow that didn't work right

rtil

ONE FUCKING SNOWFLAKE yes i was too lazy to fix his AS but it's ok his part was shit anyway!

also hnil it looked like a continuous stream to me when i made it, post your swf and show me what you mean

Hnilmik



I'm going by 25 fps, if it affects anything (which I don't think it does since this is just 1 frame so far).

 I wonder if I'm just going OCD/crazy...

rtil


Hnilmik

init = function () {
    width = 720;
    height = 550;
    max_snowsize = 5;
    snowflakes = 100;
    for (i = 0; i < snowflakes; i++) {
        t = attachMovie("snow", "snow" + i, i);
        t._alpha = 20 + Math.random() * 60;
        t._x = -(width / 2) + Math.random() * (0.5 * width);
        t._y = -(height / 2) + Math.random() * (0.5 * height);
        t._xscale = t._yscale = 50 + Math.random() * (max_snowsize * 10);
        t.k = 1 + Math.random() * 2;
        t.wind = 0.9 * (Math.random() / 2);
        t.onEnterFrame = mover;
    }
};

mover = function () {
    this._y -= this.k;
    this._x += this.wind;
    
    if (this._y < -20) {
        this._y = height+10;
    }
    if (this._x > width + 20) {
        this._x = -(width / 2) + Math.random() * (1.5 * width);
        this._y = height;
    } else if (this._x < -20) {
        this._x = -(width / 2) + Math.random() * (1.5 * width);
        this._y = height;
    }
};

init();

rtil

#8
the height in your actionscript doesn\\\'t match the height of your document

and to give the snowflakes random starting places, replace
t._x = -(width / 2) + Math.random() * (0.5 * width);
        t._y = -(height / 2) + Math.random() * (0.5 * height);


with
t._x = -(width / 2) + Math.random() * (1.5 * width);
        
        if (t._x < 0) {
            while(t._x < 0) {
                t._x = -(width / 2) + Math.random() * (1.5 * width);
            }
        }
        
        t._y = -(height / 2) + Math.random() * (1.5 * height);
        
        if (t._y < 0) {
            while(t._y < 0) {
                t._y = -(height / 2) + Math.random() * (1.5 * height);
            }
        }


for some reason when i reversed the snowflakes, all of the starting positions were out of bounds, causing the mover function to put them back at the bottom right at the start. the if/while loops make sure that if a snowflakes\\\' starting position is out of bounds, to keep trying a new random place until it\\\'s within the bounds of the frame.

also while working on this i\\\'m realizing that AS2 doesn\\\'t seem to have a real particle system, or at least whoever wrote this script is basically writing an instance for 100 individual particles. don\\\'t do anything too crazy with the particle itself or it will lag like hell

Hnilmik

 ::hugushibushu's~::

rtil

fuck yeah hugushibushus