so tick calls requestAnimationFrame that calls tick that... Doesn't it create an ever growing stack? Isn't there a way to do it with a while loop?
Annotated code: Circles bouncing off lines
11–20 of 70 posts
Re: Annotated code: Circles bouncing off lines
#12Re: Annotated code: Circles bouncing off lines
#13Very cool. Interesting bit: The outcomes of the falling balls seem to differ every time, which corroborates the fact that any minor change in initial state results in vastly different outcomes. Edit: Or am I just imagining it?
~~The simulation clock is based on the actual frame rate achieved via requestAnimationFrame().~~ Edit: Actually, it looks like the physics portion takes constant (but implicit) time steps each frame, but the time that a circle enters the simulation is based on the actual frame rate, which means when a given circle appears, the lines could be in a different location from previous runs.
Re: Annotated code: Circles bouncing off lines
#14Trying to keep the narrative of explanation in the same linear order as the code makes for a surprisingly difficult to understand item. Would be neat to see more "traditional" literate programming techniques applied here. All of that said, really cool, and seriously thank you for sharing!!
Re: Annotated code: Circles bouncing off lines
#15http://jsfiddle.net/yr64fy2o/1/
It is nice to be able to show someone directly how changing the various parameters affects the simulation.
Re: Annotated code: Circles bouncing off lines
#16OT: I'm not a game developer. What are the other patterns - besides the global state and mutation functions - that one can use for a game loop?
Re: Annotated code: Circles bouncing off lines
#17Re: Annotated code: Circles bouncing off lines
#18Re: Annotated code: Circles bouncing off lines
#19Neat! Is the code annotation page a library?