My blog has been moved to ariya.ofilabs.com.

Friday, September 24, 2010

invade & destroy

Developing games using HTML5 Canvas and JavaScript is simply the future. Something classic like Egor Balishev's RGB Invader, an entry in the 10K Apart, is usually my favorite.

If for some reasons (which I would not elaborate in this post) you need to deploy the game as a desktop or a mobile application, using Canvas and JavaScript gives another advantage: just package it with WebKit, for example QtWebKit if you do not mind using Qt.

However, since usually it is just about Canvas, often it is enough to run the game logic with a JavaScript interpreter and use some Canvas implementation for the display. This was something that I demonstrated before, i.e. running the Monster Evolution demo via JavaScriptCore and V8. Applying the same technique, and adjusting the shim so that it layers whatever RGB Invader requires, gives the following:

Basically it is using Qt Script (also in attempt to popularize it even more) along with a mix of C++/QObject and JavaScript machinery to fool the game code to think it's running in a browser environment. It was a nice afternoon fun project.

The code is in the X2 repository, find it under the javascript/invader directory. Get it while it's hot, and save our Earth!

4 comments:

er said...

So you think making games this way is quite reasonable ? either for fun or profit ?

Anonymous said...

How is the performance? Without having to have a whole WebView one would think it might be able to be much faster.

Ariya Hidayat said...

@digitalsurgeon: Yes, since you can have all deployed desktop + mobile + web version.

Ariya Hidayat said...

@Benjamin: Roughly the same speed, but that is because I do not optimize the binding to the script world, rather just relying on Qt Script's QObject bridge.