Hi,
I'd like to make a gas simulation similar to the one found on this site http://intro.chem.okstate.edu/1314f00/laboratory/glp.htm
where the molecules bounce off the walls and off each other.
I know how to make them avoid each other (with the sensing options) but so far in order to get them to move I had to program them on particular paths. What I'd really like is for them to move more randomly.
Any suggestions?
Offline
On each particle...
[blocks]<when green flag clicked>
<forever>
<turn cw( <pick random( )to( )degrees>
<move( <pick random( )to( )steps>
<if on edge, bounce>
<when green flag clicked>
<forever>
<if><touching color[ Colour of the other particles
<turn cw( <pick random( )to( )degrees>
<move( <pick random( )to( )steps>[/blocks]
That should work...
If your particles are all different colours, then you will need to do it like
[blocks]
<when green flag clicked>
<forever>
<if><touching[ the particle sprite[blocks]
As above.
Make sure you list all the particles that each particle needs to repel using this block, [blocks]<< <and> >>[/blocks] . Hope this helped!
Offline
The_Dancing_Donut wrote:
On each particle...
[blocks]<when green flag clicked>
<forever>
<turn cw( <pick random( )to( )degrees>
<move( <pick random( )to( )steps>
<if on edge, bounce>
<when green flag clicked>
<forever>
<if><touching color[ Colour of the other particles
<turn cw( <pick random( )to( )degrees>
<move( <pick random( )to( )steps>[/blocks]
That should work...
If your particles are all different colours, then you will need to do it like
[blocks]
<when green flag clicked>
<forever>
<if><touching[ the particle sprite[blocks]
As above.
Make sure you list all the particles that each particle needs to repel using this block, [blocks]<< <and> >>[/blocks] . Hope this helped!
This idea sounds pretty good. Donut's got it perfect!
Offline