0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

玉花火っぽいすくり

Last updated at Posted at 2019-06-12

なつが近づいてきました
打ち上げ花火の玉花火っぽいスクリです
ただそれだけ

ではみなさんお楽しんでね!!

タッチでオンオフ
パブチャで /999 start で開始 /999 stop で停止でも おっけー

/*
    花火っぽいスクリ
                                        13 Jun . 2019    esforco
*/
float gap;
float time = 3;  // タイマーの時間
integer ch = 999;
integer listen_handle;
integer start_flag = FALSE;

ctrl(float gap)
{
    // 引数が0なら タイマーと パーティクルを停止
    llSetTimerEvent(gap);
    if (gap == 0)
    {
        llSetPrimitiveParams([ PRIM_GLOW, ALL_SIDES, 0 ]);
        llParticleSystem([]);
    
        llOwnerSay("■ stop firework");    
        return;
    }
    
    llOwnerSay("▶ start firework");
}

perticle()
{
    vector color;  // 色用にベクトル型変数を定義
    color.x = llFrand(1);  // 0〜1までの乱数を
    color.y = llFrand(1);  // 変数のR、G、Bに
    color.z = llFrand(1);  // 入れる

    llParticleSystem([
        PSYS_PART_FLAGS,
        PSYS_PART_INTERP_SCALE_MASK| PSYS_PART_INTERP_COLOR_MASK |
        PSYS_PART_EMISSIVE_MASK,
        PSYS_PART_MAX_AGE, 2,
        PSYS_SRC_PATTERN,
        PSYS_SRC_PATTERN_EXPLODE,
        PSYS_SRC_BURST_RATE, time,
        PSYS_SRC_BURST_PART_COUNT, 300,
        PSYS_PART_START_SCALE, <0.1,0.1,0>,
        PSYS_PART_END_SCALE, <0.1,0.1,0>,
        PSYS_PART_START_COLOR, color,
        PSYS_PART_END_COLOR, <1,0.5,0>,
        PSYS_PART_START_ALPHA, 1.0,
        PSYS_PART_END_ALPHA, 1.0,
        PSYS_PART_START_GLOW, 0,
        PSYS_PART_END_GLOW, 1
    ]);
}

do_firework()
{
    // 1つめのわっか
    perticle();
    llSetPrimitiveParams([ PRIM_GLOW, ALL_SIDES, 0.2 ]);        
    llSleep(0.1);
    llParticleSystem([]);
    llSleep(0.2);
    // 2つ目のわっか
    perticle();
    
    llSleep(0.5);
    llSetPrimitiveParams([ PRIM_GLOW, ALL_SIDES, 0 ]);
    llParticleSystem([]);
}

default
{
    state_entry()
    {
        llParticleSystem([]);
        // 透明にします
        llSetAlpha(0, ALL_SIDES);
        listen_handle = llListen(ch, "", NULL_KEY, "");
    }

    touch_start(integer n)
    {
        if(start_flag == FALSE)
        {
            ctrl(time);
            do_firework();
            start_flag = TRUE;
        }
        else
        {
            ctrl(0);
            start_flag = FALSE;
        }
    }

    listen( integer channel, string name, key id, string message )
    {
        if(message == "start" && start_flag == FALSE)
        {
            ctrl(time);
            do_firework();
        }
        else if(message == "stop")
        {
            ctrl(0);
        }
    }

    timer()
    {
        do_firework();
    }
}

Snapshot_010.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?