stop button, loop skipped a frame
This commit is contained in:
11
main.js
11
main.js
@ -8,11 +8,12 @@ const dead = document.querySelector('#dead');
|
||||
const live = document.querySelector('#live');
|
||||
const startBtn = document.querySelector('#start');
|
||||
const resetBtn = document.querySelector('#reset');
|
||||
const stopBtn = document.querySelector('#stop');
|
||||
const cellSize = document.querySelector('#cellSize');
|
||||
const loop = document.querySelector('#loop');
|
||||
|
||||
canvas.width = main.offsetWidth;
|
||||
canvas.height = main.offsetHeight;
|
||||
canvas.width = main.offsetWidth * 0.9;
|
||||
canvas.height = main.offsetHeight * 0.9;
|
||||
|
||||
// TODO: Hide iterator inside
|
||||
function evolve(state, acc, rules) {
|
||||
@ -89,7 +90,7 @@ async function draw(state, acc) {
|
||||
await sleep(40);
|
||||
|
||||
const newAcc = () => {
|
||||
if (position >= canvas.height && loop.checked) return 1;
|
||||
if (position >= canvas.height && loop.checked) return 0;
|
||||
return acc;
|
||||
};
|
||||
|
||||
@ -118,3 +119,7 @@ startBtn.addEventListener('click', async () => {
|
||||
resetBtn.addEventListener('click', async () => {
|
||||
reset();
|
||||
});
|
||||
|
||||
stopBtn.addEventListener('click', async () => {
|
||||
drawing = 0;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user