elfs: (Default)
[personal profile] elfs
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)
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

elfs: (Default)
Elf Sternberg

December 2025

S M T W T F S
 12345 6
78910111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Dec. 30th, 2025 04:09 pm
Powered by Dreamwidth Studios