-
Notifications
You must be signed in to change notification settings - Fork 0
Home
hacknorris edited this page Oct 20, 2025
·
2 revisions
Welcome to the life api wiki!
how to include on a website:
<script src="https://hacknorris-code.github.io/life/things.js"></script>main api usage:
var = new GameOfLife(
str {canvas id},
*str {foreground color, black by default},
*int {probability - best between 0 and 10, bigger - more probable for cell to appear at start, 5 by default},
*bool {debug mode - console.logs in few important parts of code}
);where *-signed attribute is optional
api to update canvas:
var.init();
var.updateAndDrawGrid();example usages:
automatical, simple:
<body onload="main()">
<script src="https://hacknorris-code.github.io/life/things.js"></script>
<canvas id="main"></canvas>
<script>
function main(){
let game = new GameOfLife('white');
game.init();
setInterval(() => {
game.updateAndDrawGrid();
}, 100);
}
</script>
</body>manual, complex:
<body onload="main()">
<script src="https://hacknorris-code.github.io/life/things.js"></script>
<canvas id="main"></canvas>
<button onclick="next()">NEXT</button>
<script>
function main(){
let game = new GameOfLife('white', 'grey', 3,true);
game.init();
}
function next(){
game.updateAndDrawGrid();
}
</script>
</body>