Conway's Game of Life in HTML5
simon.lc
simon.lc
Minified JavaScript :(
But from one Simon (canvas lover) to another I decided to chewing through the plastic bars of minification to see what was going on. In your loop you're doing:
beginPath()
arc()
fill()
You could get away with nothing but arc() and moveTo() in your loop instead and make it a bit more efficient on slower (mobile) devices, because only one new path has to get created.Your moveTo's x coordinate is going to need to be offset by the radius since thats where each starts. So it would look something like this:
s.beginPath()
loop start
s.moveTo(10 * b + 5 + 4, 10 * c + 5)
s.arc(10 * b + 5, 10 * c + 5, 4, 0, 2 * Math.PI, d)
loop end
s.fill()
I didn't try out the code, just typing in the open air here, but it should work.That's a great tip! I love little optimizations like that, thanks for the input. :)
Great work, btw! Now everyone can play the game of life! :)
- Saving the state of the 'creation stage'
and resetting it when the player clicks a restart button.
So you can experiment without having to redraw everything.
- Wrapping cells around border (think Super Mario Bros 2.)
- Easier drawing, using click and drag.
For those that have already tried it will likely need to clear their cache with ctrl+f5.http://willbailey.name/conway/index.html
The discussion: http://news.ycombinator.com/item?id=2555071
The annotated source: http://willbailey.name/conway/docs/conway.html
[1] http://en.wikipedia.org/wiki/Methuselah_(cellular_automata)
As a side note, posted on HN the other day: https://www.google.com.au/search?hl=en&q=conways%20game%...
I have a few ideas that I want to try and implement next week, hopefully to differentiate the game's everyone's been sharing.
.**
**.
.*.
.*.
..*
*** ***.
*..*
.*.*
..** |0|0|0|
|0|_|0|
|0|_|0|
or |_|0|_|
|_|_|0|
|0|0|0|