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: about 1 month 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 (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T19:43:59.000Z (almost 2 years ago)
- Last Synced: 2024-11-18T23:56:18.079Z (3 months 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
[](https://codeclimate.com/github/ggiuffre/conway/maintainability) [](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.