Spawning help

About advanced scenes, and the Thyme scripting language used in Algodoo.

Spawning help

Postby Nisheeth » Thu Mar 31, 2011 11:32 am

I wanted to spawn a circle on collision that was slightly transparent and of Grey color and would fly in the sky.
I used the following code :
Code: Select all
(e)=>{
    scene.my.addcircle({
        pos := e.pos;
        density := 0.0001;
        color := [0.27, 0.24567446, 0.19845001, 0.645];
        radius := 0.01;
        collideSet := 64;
        collideWater := false;
        drawCake := false
    })
}

But when I play the scene, the circles fall down rather than float up (as they should since they have such a low density.)

Please help
Nisheeth
 
Posts: 99
Joined: Thu Mar 31, 2011 11:15 am

Re: Spawning help

Postby Kilinich » Thu Mar 31, 2011 2:48 pm

maybe you just turn off air? ;)
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Spawning help

Postby Nisheeth » Thu Mar 31, 2011 4:18 pm

Ah. Thanks. It worked. By the way is there a way to make those circles spread out after they spawn rather than go in a straight line?
Thanks in advance.
Nisheeth
 
Posts: 99
Joined: Thu Mar 31, 2011 11:15 am

Re: Spawning help

Postby Someone Else » Thu Mar 31, 2011 5:25 pm

Try the following:

Make sure Air is turned on. You may need to expand the menu with Play/Pause, Undo, and Redo.
Make the density := 0.001. This, I think, is the smallest positive number Algodoo will accept in that field.
If this causes the circles to float too slowly for you, try adding this bit of code to the spawning code:
Code: Select all
airFrictionMult = 0.01

This will have the effect of making the circles thinner, so air friction has less effect. And the circles will float faster. The lower the number, the faster it will float.

Note: I started typing the above before I saw Kilinich's post.

As for making them go in different directions, try either setting vel to a random function (Kilinich can show you one). Or, spawn two circles by doubling the code-
Code: Select all
scene.addCircle ({ blahblah});
scene.addCircle ({blahblah})


And for random velocity, use
Code: Select all
vel := [scene.my.rnd, scene.my.rnd]
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Spawning help

Postby TC42 » Thu Mar 31, 2011 5:50 pm

Umm... SE, I think you have to define the scene.my.rnd function before you can use it. :angel:
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Spawning help

Postby Kilinich » Thu Mar 31, 2011 6:48 pm

Nisheeth wrote:Ah. Thanks. It worked. By the way is there a way to make those circles spread out after they spawn rather than go in a straight line?
Thanks in advance.


set initial speed to "flow" spawned circles
vel := [sin(time),0]
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Spawning help

Postby Nisheeth » Thu Mar 31, 2011 8:14 pm

Could you please explain it? I didn't understand it. I have just started using thyme.
Nisheeth
 
Posts: 99
Joined: Thu Mar 31, 2011 11:15 am

Re: Spawning help

Postby Kilinich » Thu Mar 31, 2011 9:38 pm

vel is initial velocity [Vx,Vy]
sin(time) is just a function that set velocity depends on simulation time. You can use any function here.
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Spawning help

Postby Nisheeth » Thu Mar 31, 2011 9:41 pm

It didn't workout for some reason. I put it in the scene.addcircle.
It was:
Code: Select all
(e)=>{
    scene.my.addcircle({
        pos := e.pos;
        density := 0.001;
        color := [0.27, 0.24567446, 0.19845001, 0.645];
        radius := 0.03;
        collideSet := 64;
        collideWater := false;
        drawCake := false;
        vel := [sin(time), 0]
    })

By the way I wanted to simulate dense smoke.
Nisheeth
 
Posts: 99
Joined: Thu Mar 31, 2011 11:15 am

Re: Spawning help

Postby Someone Else » Sat Apr 02, 2011 5:58 am

@TC42: I knew that.

Try vel := [math.sin(sim.time), 0].

And for dense smoke, you probably want to set collideSet := 0 and use "random" velocity. And low airFrictionMult.
Or perhaps collideSet := 64;
heteroCollide = true.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Spawning help

Postby Nisheeth » Sat Apr 02, 2011 6:04 am

Is there a way to set a timer so that after a set amount of time it falls down rather than go up?
Nisheeth
 
Posts: 99
Joined: Thu Mar 31, 2011 11:15 am

Re: Spawning help

Postby Someone Else » Sat Apr 02, 2011 6:36 am

Umm... Spawn a laser on the circle that gradually increases e.geom.density over time?

Try this:
Code: Select all
    scene.addCircle({
        geomID := 3141;
        pos := e.pos;
        airFrictionMult := 0.1;
        density := 0.001;
        color := [0.27, 0.24567446, 0.19845001, 0.645];
        radius := 1.0;
        collideSet := 64;
        collideWater := false;
        heteroCollide = true;
        drawCake := false;
        onHitByLaser := (e)=>{};
        vel := [(math.sin(sim.time * 100)) * 10, 0]
    });
    scene.addLaserPen({
        pos := e.pos;
        geom := 3141;
        maxRays := 1;
        collideSet := 64;
        onLaserHit := (e)=>{};
        size := 0.3
    })


It spawns circles significantly bigger than the original circles, but in such a way as to make it actually look like dense fog. Every single circle also has a small laser attached. However, I have not figured out how to make it actually change density more than once.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Spawning help

Postby Nisheeth » Sat Apr 02, 2011 10:06 am

Thanks. Its now behaving like smoke. But it is not dense. I was making a volcano. No the smoke was the one that accompanied the eruption. It is dense enough to fall down after the force that threw it up dies out. So it is supposed to be thick smoke, but it is too thin smoke.

By the way I did try using the code multiple times (as you suggested before). But apparently there was no effect.
Nisheeth
 
Posts: 99
Joined: Thu Mar 31, 2011 11:15 am

Re: Spawning help

Postby Someone Else » Sat Apr 02, 2011 8:50 pm

I added to that code (the scene.addCircle part) a bit that makes the circles not collide with each other. That's what heteroCollide does. If you want something more volcanic ash-like, try this:
Code: Select all
        scene.addCircle({
            pos := e.pos;
            airFrictionMult := 0.1;
            density := 0.011;
            color := [0.27, 0.24567446, 0.19845001, 0.645];
            radius := 1.0;
            collideSet := 64;
            collideWater := false;
            heteroCollide = true;
            drawCake := false;
            onHitByLaser := (e)=>{};
            vel := [(math.sin(sim.time * 100)) * 10, 50]
        })

This will spawn the circles with a constant upward velocity (I think) and they will be a bit denser than air.
If they spawn moving downward, change the vel(1) from 50 to -50.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Spawning help

Postby Nisheeth » Sun Apr 03, 2011 7:46 am

It worked. Thanks. Just one final problem. They are too large for my scene, actually larger than my volcano!
I tried reducing the radius to 0.3 (the correct size), but it didn't seem like smoke any more. I couldn't increase the size of the Volcano as well because it was using large amounts of water in a small place to cause the eruption.
Nisheeth
 
Posts: 99
Joined: Thu Mar 31, 2011 11:15 am

Re: Spawning help

Postby Someone Else » Sun Apr 03, 2011 8:27 am

Decrease the velocities.

Try vel := [(math.sin(sim.time * 100)) * 3, 15]

This should be correctly scaled.

On the other hand, I think you will really like this. I figured out how to change density over time.
Code: Select all
    scene.addCircle({
        geomID := 3141;
        pos := e.pos;
        airFrictionMult := 0.1;
        density := 0.001;
        color := [0.27, 0.24567446, 0.19845001, 0.645];
        radius := 0.3;
        collideSet := 64;
        collideWater := false;
        heteroCollide = true;
        drawCake := false;
        onHitByLaser := (e)=>{e.geom.density = e.geom.density + 0.0003};
        vel := [(math.sin(sim.time * 124)) * 3, 0]
    });
    scene.addLaserPen({
        pos := e.pos;
        geom := 3141;
        maxRays := 1;
        collideSet := 64;
        onLaserHit := (e)=>{};
        size := 0.03
    })
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Spawning help

Postby Nisheeth » Sun Apr 03, 2011 8:42 am

Thanks a lot It worked perfectly. But what did you do to increase its density?

And here is the volcano I had been making:
Rating: rated 5
Filesize: 61.1 kB
Comments: 0
Ratings: 1
download
Nisheeth
 
Posts: 99
Joined: Thu Mar 31, 2011 11:15 am

Re: Spawning help

Postby Someone Else » Sun Apr 03, 2011 6:58 pm

The density increasing code is in the circle's onLaserHit. Or is it onHitByLaser? I can't remember.... It's onHitByLaser.

And I made some tweaks on the volcano:
Rating: rated 5
Filesize: 34.22 kB
Comments: 1
Ratings: 1
download


Very interesting using tracers to thicken smoke without lag.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Spawning help

Postby Nisheeth » Mon May 23, 2011 6:23 am

What didn't you understand?
Basically the codes here create the smoke from the volcano, that will go to a height and then begin to fall down.
Nisheeth
 
Posts: 99
Joined: Thu Mar 31, 2011 11:15 am

Re: Spawning help

Postby Someone Else » Thu May 26, 2011 3:24 am

Who didn't understand what?
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 1 guest