Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ggiuffre/conway

A famous zero-player game...
https://github.com/ggiuffre/conway

canvas game-of-life javascript

Last synced: 1 day ago
JSON representation

A famous zero-player game...

Awesome Lists containing this project

README

        

# Conway's Game of Life

[![Maintainability](https://api.codeclimate.com/v1/badges/24df6590869950d2dea1/maintainability)](https://codeclimate.com/github/ggiuffre/conway/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/24df6590869950d2dea1/test_coverage)](https://codeclimate.com/github/ggiuffre/conway/test_coverage)

A JavaScript implementation of Conway's
[Game of Life](https://www.conwaylife.com/wiki/Conway%27s_Game_of_Life)
with a simple HTML canvas.

## Preview

Check out a demo at
[https://ggiuffre.github.io/conway/](https://ggiuffre.github.io/conway/).

## Usage

Download `conway.js`
from this repository.

Add an HTML `canvas` element and a `script` element pointing to `conway.js`:

```html
Stop using IE 8!

```

Fire up the game with this additional `script`:

```html

const canvas = document.querySelector('#conway');
const width = canvas.width = canvas.parentElement.clientWidth;
const height = canvas.height = canvas.parentElement.clientHeight;
const ctx = canvas.getContext('2d');
const game = new Game(ctx, width, height);
game.setRandomState();
game.start();

```

If you don't want the game to be full-page, make sure to remove
`canvas.parentElement.clientWidth`/`Height` from the script above,
and set the width and height of your `canvas` element with CSS.