{"id":17528729,"url":"https://github.com/jafb321/react-game-life","last_synced_at":"2025-04-23T18:23:36.458Z","repository":{"id":44723843,"uuid":"512961245","full_name":"JAFB321/react-game-life","owner":"JAFB321","description":"React hook to easily create a Game of Life","archived":false,"fork":false,"pushed_at":"2022-11-27T03:48:35.000Z","size":16,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T19:50:13.442Z","etag":null,"topics":["canvas","game-of-life","react"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-game-life","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JAFB321.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-12T01:39:05.000Z","updated_at":"2023-02-09T06:30:50.000Z","dependencies_parsed_at":"2023-01-21T19:30:37.670Z","dependency_job_id":null,"html_url":"https://github.com/JAFB321/react-game-life","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JAFB321%2Freact-game-life","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JAFB321%2Freact-game-life/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JAFB321%2Freact-game-life/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JAFB321%2Freact-game-life/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JAFB321","download_url":"https://codeload.github.com/JAFB321/react-game-life/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250488323,"owners_count":21438761,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["canvas","game-of-life","react"],"created_at":"2024-10-20T15:44:45.243Z","updated_at":"2025-04-23T18:23:36.426Z","avatar_url":"https://github.com/JAFB321.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Simple react hook to create amazing game of life automats.\r\n\r\n### Install 🐱‍💻\r\n```bash\r\nnpm i react-game-life\r\n```\r\n\r\n### Basic usage 💡\r\n```javascript\r\nimport React from 'react'\r\nimport {useGameLife} from 'react-game-life'\r\n\r\nexport default function App() {\r\n    \r\n    const [game, canvasRef] = useGameLife();\r\n    \r\n    return (\r\n        \u003ccanvas ref={canvasRef}\u003e\r\n        \u003c/canvas\u003e\r\n    )\r\n}\r\n```\r\n##### Result:\r\n![Game life dark demo](https://raw.githubusercontent.com/JAFB321/JAFB321/main/game-life-dark.gif)\r\n\r\n##### How to use\r\n- Drag to explore the board\r\n- Double click to spawn/kill cells\r\n- Mouse wheel to zoom in/out\r\n- Enter to start/pause evolution\r\n- +/- keys to speed up/down\r\n\r\n##### You can also pass default config\r\n```javascript\r\nimport React from 'react'\r\nimport {useGameLife} from 'react-game-life'\r\n\r\nexport default function App() {\r\n    \r\n    const [game, canvasRef] = useGameLife({\r\n      game: {delay: 100},\r\n      graphics: {\r\n        colors: {background: \"#FFF\", cell: \"0E0E0E\"},\r\n        board: {height: 800, width: 1200}\r\n      }\r\n    });\r\n\r\n    return (\r\n        \u003ccanvas ref={canvasRef}\u003e\r\n        \u003c/canvas\u003e\r\n    )\r\n}\r\n```\r\n##### Result:\r\n![Game life white demo](https://raw.githubusercontent.com/JAFB321/JAFB321/main/game-life-white.gif)\r\n\r\n### To manually interact/customize the game just add 🤖:\r\n```javascript\r\nuseEffect(() =\u003e {\r\n    game.bornCell({x: 10, t: 10}) // Spawn cell\r\n    game.killCell({x: 10, y: 10}) // Kill cell\r\n    game.startEvolution()         // Start \r\n    game.stopEvolution()          // Stop\r\n    game.speedUp(1.5)             // Speed up 1.5x\r\n    game.speedDown(0.8)           // Speed down 0.8x\r\n    game.graphics.setConfig({     // Change graphics config\r\n        colors: {background: '#F0F0F0', cell: '#000000'}\r\n    })\r\n    // and more\r\n}, [])\r\n```\r\nYou can use the \u003ccode\u003egame\u003c/code\u003e object where you want to call it's methods (The useEffect is optional, you can use the game inside a simple function)\r\n\r\n##### Game API  🚀\r\n[Game life repository](https://github.com/JAFB321/game-life)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjafb321%2Freact-game-life","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjafb321%2Freact-game-life","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjafb321%2Freact-game-life/lists"}