Life simulation

Categories: howto

How to make a little life simulation in javascript in browser, found easy to learn repo with various life patterns by @brainxyz

This kind of code is ideal for education of javascript canvas using, its easy to understands and works in browser.

I’ve modified code a little, and achieve some stability with virus like structures which consume other particles.

Here is a gist for that code:

How it works:

  • There is a js canvas where all drawing is happening
  • There is an atom entity which is structure of position(x,y), velocity(x,y), color
  • Threr is a rule function which defines relations between particles
  • There is a configuration object that defines relation between particles using rule method
  • There is infinity loop of animation
  • Before animation starts it creates arrays of different types of particles


Interactive example in details below

No webmentions were found.

Comment with an Email

No comments here yet Write here gently