game_of_life_simulation

1.0.4 • Public • Published

Game Of Life

Intro

This package propose a JS implementation of Conway's Game Of Life.
Its initial aim is to be embedded in web pages as an animated background.

Installation

With Git

The sources are available on gitlab. They can be retrieved using the following commands.
1 - mkdir project_directory
2 - cd project_directory
3 - git clone https://gitlab.com/acur28/gameoflife.git

With npm or yarn

create a new project using your favorite package manager:
npm install game_of_life_simulation
or
yarn add game_of_life_simulation

Usage

Once the sources have been retrieved, you can use this package either in standalone with parcel, or as a module to be used in your own project:

Standalone

Build the project using npm install or yarn Run parcel index.html and follow the url it will provide you. You can control the simulation through 2 buttons:

  • the first one will pause / resume the simulaiton
  • the second will reset the simulation

in a project

import the Grid class using import Grid from "game_of_life_simulation" Create a new instance using the following options, passed as an object:

  • 2D size of the grid you'd like to render, in cells
  • the width and height of individual cell elements
  • the color of the background
  • the color of the cells

The init() method will return a DOM object, which is the root of the game's grid. You can use this object to position the grid wherever you want in your page (I personally use it as a background) The run() method will start the simulation. You can provide it with a delay (in ms) between each game's frame (500ms by default)

There is no "default" CSS stylesheet in the module: the style is managed by the script

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i game_of_life_simulation

    Weekly Downloads

    4

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    10.2 kB

    Total Files

    11

    Last publish

    Collaborators

    • acur28