Javascript game development 2: screen

My idea is to involve you in the process of making a game. Maybe it would have been better to begin wit this chapter, but anyways. After I explained a way to organize javascript code, we can use this for an practical example. So will make an screen object that manages it self.
Because we need only one screen, we would maybe do good to solve this with a singleton pattern. But in Javascript we can simply create an object with “{}”, so there’s no constructor and you can’t make instances of it. I call this type of object “module”. The difference to an object that I handle under “object”, is that an object can be instanced with new.

The index.html is a html document with the html5 doctype and utf-8 character coding. It includes the jQuery framework.
Like in explained here “javascript plugin system“, the modules are loaded asynchrony over AJAX. After any loaded script, the previous defined callback function is executed. In case of the screen, its initialized and filled up with red color.

Archives

Categories

Meta

I just wrote a library as a backbone for JavaScript applications. You can download it on GitHub. Features creating instances of “classes” automatic creation of getter- and setter methods for properties getter and setter can …