Unified game engine demos for flash, HTML5 (and more)
In my previous post, I outlined the benefits of a platform agnostic language and game engine. Here are some demos, showing basic sprite movement via scripts, and mouse/touch+gesture (iOS only sorry) input on a parallax enabled view:
There is no change in the game code in these demos. The only differences are compiler switches, and the HTML page that embeds each of them.
I'm going to repeat for emphasis: there is no change in the code for device input (or anything else). The mouse pans the parallax scene identically on flash, HTML5 canvas, and CSS transformed div and image elements.
Where needed, individual game components use platform specific methods that are aware of the target platform, but these are well isolated and are kept as low level as possible.
As you can see, CSS transforms are pretty performant, and definitely better on iOs devices. Touch screen phones and ipods etc have pretty good screens, meaning the canvas element has to be pretty large to fit the entire screen, which then runs like a dog. By using CSS transforms, you can use static images or animate using mini canvas elements, and avoid having to redraw large swathes of the screen.
If another platform came along tomorrow, the only classes to write anew would be a resource loading class, raw device input, and raw rendering (and sound). The higher level stuff is all handled by haxe itself then the game engine on top of that. It means as a developer, you are not chained to a particular platform, and can move to other platforms with relative ease.
Were these examples actual playable games, they are deployable almost anywhere: desktop computers/laptops (flash, c++), android phones (flash), iOS devices (HTML5 stuff). Did I mention Haxe compiles to multiple server-side languages as well?
It seems that the paradigm of write once/run anwhere is served better by a platform agnostic language, rather than a platform needs to be developed for all platforms.
The source for the engine and these demos are available here.