I recently wrote a game, and found it very much like developing a Javascript-based web application. (My wife, who's a journalist with the video game industry beat, insists "it's a toy, not a game. There is a difference." I will defer.)
If you're a web developer who does a lot of Ajax, there is one kind of event in which you're often very interested. Most events describe what just happened, but advanced Ajax and DOM coding often rely more on what just stopped happening. The Image.onload() and the XHR (XMLHTTPRequest) objects' onreadystatechange handlers are interesting because they tell us when something that takes time is done, not when something has begun.
Another, related component of javascript development is setTimeout(). setTimeout is basically on(when clock reaches this point)=somefunc(). It's not worded that way, but eventually you'll wrap your mind around that basic idea. setTimeout() is just another way of shoving something into the list of events. Along with all the objects on the screen, each of which might have one or more events associated with it, there's a general object, the clock, to which you hook up events with setTimeout(). When you understand this, you'll realize the basic truth:
Everything in web application development is event-driven. Everything. The same is true of games.
(Read the rest at ElfSternberg.com)
If you're a web developer who does a lot of Ajax, there is one kind of event in which you're often very interested. Most events describe what just happened, but advanced Ajax and DOM coding often rely more on what just stopped happening. The Image.onload() and the XHR (XMLHTTPRequest) objects' onreadystatechange handlers are interesting because they tell us when something that takes time is done, not when something has begun.
Another, related component of javascript development is setTimeout(). setTimeout is basically on(when clock reaches this point)=somefunc(). It's not worded that way, but eventually you'll wrap your mind around that basic idea. setTimeout() is just another way of shoving something into the list of events. Along with all the objects on the screen, each of which might have one or more events associated with it, there's a general object, the clock, to which you hook up events with setTimeout(). When you understand this, you'll realize the basic truth:
Everything in web application development is event-driven. Everything. The same is true of games.
(Read the rest at ElfSternberg.com)