|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Version 2.0, November 2008After much harassment from friends to extend Tom's Halls into a more fully-fledged game, I finally found the time to do so. The result is Tom's Halls v2.0 which you can play online at www.tomshalls.net. You can now explore a multitude of dastardly rooms awash with terminally geeky humour and private in-jokes. Be warned! Technical Changes and Improvements
Observations with ChromeSince the launch of the original, the Chrome browser has appeared on the scene. My findings with Chrome were much like those with Opera during development of the original: Chrome's optimizations, apparently and unsurprisingly, are not towards this type of application. Compared to Firefox and IE7 the DOM access is painfully slow and erratic. Chrome also has an annoying habit of freezing up some seconds after first loading the page and then apparently reloading the page or rebuilding the DOM, effectively resetting your game. Finally, using dynamic opacity on even a single small sprite on the screen drastically slows down the entire screen. For this reason I canned my original approach to the flashing collectables which had them fading smoothly in and out, opting instead for an 80's-style flashing every half second.
IntroductionTom's Halls is / was a learning project to develop a simple 2D platform game engine using JavaScript DOM manipulation and CSS. My main intention was to upskill on the following:
I chose to develop the code from the ground up rather than building upon third party libraries such as Prototype, partly for reasons of learning how these libraries actually do their thing, and partly to avoid their bloat factor and the sometimes reported risk of them not always playing nicely alongside other code. Use the DOM, LukeDOM My original approach to collision detection was to check each DOM element's position and dimensions directly by interrogating the I therefore chose to create an Game LoopA 15ms interval is used to call the main game loop, which does the following:
Screen Definition and LoadingThe "entire game" (all two screens of it, at this stage) takes place in the one XHTML page Default.htm. Each game screen is defined in its own JavaScript file, named by its
This approach means that technically as many new screens as desired can be added without altering the main engine, or (I would hope) increasing the amount of memory utilized. I admit I have not done in-depth profiling of browser memory as JavaScript files are linked and unlinked and DOM elements added and removed. I presume it depends upon how garbage collection is implemented (or not). I would be interested to hear from anyone with expertise in this area. W3C Standards and Browser BehaviourI'm quite pleased to have been able to get this game to validate as XHTML (1.0) Strict, with all JavaScript unobtrusively linked. It is thus far tested and known to work in Firefox, Opera, and Internet Explorer 7 on PC. I did have it basically working in Internet Explorer 6 (after a few CSS hacks, which pained me greatly) but then gave up on the effort and have not yet been able to preview the latest version in Internet Explorer 6. It is not a commercial "site" and the intention was to upskill on standards-based approaches rather than to absolutely maximize compatibility. Therefore I'm happy with my decision not to introduce the clutter of conditional browser comments or any further CSS hacks. One point of note regarding browser performance is that while Opera, in my experience, is generally the fastest browser of the three mentioned above, when it comes to JavaScript-manipulated DOM elements, it seems to be the slowest by a large margin. It appears to slow down dramatically as the number of moving sprites increases. I have just upgraded to version 9.25, which seems to be faster than the previous version, but it still struggles compared to Firefox and Internet Explorer 7. ConclusionWhile my field of work does not involve any kind of game development, the extra understanding I've gained through this project has already served me well in our commercial undertakings, most of which directly or indirectly leverage JavaScript to varying degrees. Hopefully, some of the approaches might be useful to others. I make no claims that this code is perfect, as large parts of it are fairly new to me! Comments and helpful criticism are much appreciated.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||