Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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...
- Host: GitHub
- URL: https://github.com/ggiuffre/conway
- Owner: ggiuffre
- License: mit
- Created: 2020-05-06T08:18:34.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T19:43:59.000Z (over 1 year ago)
- Last Synced: 2023-04-25T18:34:56.963Z (over 1 year ago)
- Topics: canvas, game-of-life, javascript
- Language: JavaScript
- Homepage: https://ggiuffre.github.io/conway/
- Size: 355 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.