In a place where your fantasy can roam free, there won't be any boundaries to what your imagination can create.
Misha’s Tech Playground
graphics, fun and code play
I'm crazy - but who cares? My ideas are constantly dwelling and this is the place for them to pour out and form into something good. Only active participation will ultimately make this place come to life.
Is JavaScript enough for browser based games
Most Browsergames these days are done with Flash. Sure, Flash is a nice technology and it has lots of benefits over X3D, Quicktime, Silverlight and others. The main reason Flash is used for games though is because it has a huge market penetration. Somewhere around 98% if you believe in Adobe’s statistics.
That there is another, mostly underestimated player is a fact that this article want’s to shed some light on.
The forgotten stepchild
There is one technology however that has a greater market share - JavaScript (or JScript on MSIE).
I’ll stick with the term JavaScript or JS, since Microsoft merely copied JavaScript and implements most of JS 1.5 even if their versions differ.
If a browser is capable of displaying Flash content it might well be able to execute JavaScripts too.
In times of web based office applications it would be only natural to think that this so called Web 2.0 (or even 3.0 as some people already state) is able to transfer to web games as well.
Why Javascript is neglected
On the processing side JS might be capable, however the graphics and sound side is still lacking fundamental improvements. Sure there is SVG, but only the minority of Browsers implements it and those implementations differ quite a bit in terms of features. The other big player in the browser market doesn’t even implement it at all (you’d need a plugin again). Sound and video isn’t even possible at all without plugins.
JavaScript on it’s own can move sprites around, it can be used to do simple frame based animations and transitions. It can’t do transformations and it takes lot’s of work to make an application look consistent across browsers (though that s not a flaw of JS itself).
It could be done
Therefore if a developer wants to leverage JavaScript for a web game he / she has to go for the smallest common denominator. Simple maze or puzzle games are quite possible just with Javascript alone, even more demanding games like Lemmings can be done just with a few Images and JavaScript.
The problem is when it comes to more advanced animations, particles, cinematics or sound effects and music. For such things the developer still has to turn to plugins. And at this point it becomes apparent that starting the sound effect and the animation for an explosion simultaneously can become quite a challange.
However, I think JavaScript is a great technology and it just isn’t recognized as such.
It all depends on the concept
People have developed stunning computer games already a long time ago when there was no mention of 3d hardware or sound cards. For a web based game we don’t necessarily need .h264 video or surround sound or even particle dynamics.
I think if developers start to focus more on usability, playability and fun we’ll be able to leverage simple yet powerful technologies more to provide great concepts that are simply fun and entertaining.
Tags: code performance, pbbg
10 Responses to “Is JavaScript enough for browser based games”
Leave a Reply
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
I think JavaScript is capable of programming any game. It’s whether or not a browser can handle it that is the real question. If you can have an embedded runtime environment optimized strictly for gaming (fast iterators, style manipulation) etc. Rip out the entire security engine (perhaps why most browsers get slow), I think you can get something pretty solid. I was able to make Tetris with some sound using just JavaScript (of course a small invisible swf file to trigger sound)
http://www.dustindiaz.com/basement/tetris-s.html
That was the point I tried to make with this article. JavaScript is a very capable and very powerful language. It’s biggest issue is that it is running in a sandbox with slow graphics access. The browsers are the constraining element…
SVG seems to be a solution on the graphics side. Opera has a nice concepts for this and Firefox is making progress also. Though all browsers have yet to implement it in a common way.
check out my website - http://www.jspuzzles.com - to play jigsaw puzzles online…
I totally agree with the statement that most of the programming that is done with Flash can be done with JS.
I think a lot of developers turn to Flash as it “seems” easier to develop in.
I’ve done an RPG tactical game and had the option of going with Flash or JS. I choose JS and am happy about the choice.
http://www.battleforcesonline.com
For rookies Flash certainly is easier. It comes with all the basic routines needed for games. Come to think of collision control, sound, and decent event handlers for objects. Timing in Flash is also quite easy and exact compared to JS. Graphics can have any shape, not just rectangular.
Though JS gives you quicker results for easy graphics display and you don’t have to deal with file loaders.
Right now I am looking into SVG in Mozilla and Opera. It seems this gives much better graphics performance than straight HTML. So maybe this is another plus for JS then
I totally agree with Dustin Diaz - as well I agree, that SVG could do it, if the implementations won´t differ and the reach would be higher - and that´s a petty
Very useful information
I see there are realy good tips. I am going to use some of them
Performance comparison between HTML, SVG and Canvas…
I already found out that using scroll properties is good for fast map scrolling. I extended the concept, and after posting my code to animate sprites via a containers scroll properties I thought hey, why not just check if there’s anything better….
Good thread, i like these tips, its looks that i knew just small part.
Ciekawy post, dodalem twoja strone do ulubionych, bede tu zagladal czesciej, pozdrawiam