![]() Store the position of this cell in the grid You can choose to draw a square or go for another shape, like the circles used in this tutorial. Start by creating a new Cell class and implement a draw() method. A cell has about 50% chance to start alive, but you can easily tweak that percentage to create different starting situations. When a new cell is created, its state of being is determined randomly. Each state will be drawn with a different color. It doesn't have to be smart, it's just a square on a grid that can be either alive or dead. Let's start by creating the framework for a single cell. ![]() Define the appearance and behaviour of a single cell Here's an example of a Gosper glider gun:įor this tutorial you're not going to use paper, but going to create The Game of Life with JavaScript on the HTML5 canvas and generate starting positions and new generations through code. Real fanatics are even looking for so called guns and spaceships (or gliders), patterns that will emit cells or look like a moving object. You can play this game on paper and think of initial starting states that will result in interesting shapes or even moving objects. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |