Live data from Hacker News

HTML5 as a gaming platform

blog.avd.io

11–20 of 31 posts

Re: HTML5 as a gaming platform

#11
post #4

Earlier quoted context omitted.

But that might shift in the future, we might be looking at a time when the only version you need to make is the web version, even for non-casual games. Unless your game requires or will requires heavy duty CPU and lot of RAM. In which case, you would need to wait several generation before a phone can run your game. Think of FPS shooters of today, except the resource spending is inverted from the art department to the…

Phones need serious improvement to run these kinds of games anyway, we're probably looking at at least half the time it's going to take for these games to run with the web technology stack on the mobile to get it running even natively on the mobile. So for mobile, the wait is on, no matter what. It's going to take a while, but our toolkits need sharpening as well, so I'm not expecting a non-trivial web game to emerge…

A cross between simulation and RTS game. You're supposed to build up a colony and manage your society. The details are not too abstract, as all units you see will have individual names and the details of your infrastructure are pipes, conveyor belts, workshops, electrical lines, generators, and so on.

You could say it's a "dwarffortress" except the details are totally different. For example, chopping down trees will not kill dwarves, but it does in my game. Production and logistics in my game is a lot smarter to prevent players from worrying about managing food production so that they can worry about more interesting things.

It's a very ambitious project for sure, and I am not expecting to complete the game until many decade latter. I am in this project at about 4 Kloc of code, yet a completed RTS game is about 40 Kloc. Mine will be bigger than this.

The main challenge in doing this project is whether or not I have the ability to slog it out for several decades and the ability to resist temptation to rewrite the whole codebase at once.

Re: HTML5 as a gaming platform

#12
post #4

Earlier quoted context omitted.

But that might shift in the future, we might be looking at a time when the only version you need to make is the web version, even for non-casual games. Unless your game requires or will requires heavy duty CPU and lot of RAM. In which case, you would need to wait several generation before a phone can run your game. Think of FPS shooters of today, except the resource spending is inverted from the art department to the…

Phones need serious improvement to run these kinds of games anyway, we're probably looking at at least half the time it's going to take for these games to run with the web technology stack on the mobile to get it running even natively on the mobile. So for mobile, the wait is on, no matter what. It's going to take a while, but our toolkits need sharpening as well, so I'm not expecting a non-trivial web game to emerge…

[deleted]

Re: HTML5 as a gaming platform

#13
post #7

I was hoping for a more technical article - the core techs for HTML5 gaming aren't quite from what I can tell. WebGL and the Audio APIs in particular seem on shaky ground for the moment... it seems there are still rather major security and performance problems to deal with. Most worrying however is the utter lack of any non-TCP networking in the browser, not even at the specification-proposal stages. Any sort of real…

> I was hoping for a more technical article

Sorry to disappoint, there are a lot of more technical articles out there, I wanted to look at this more from the perspective of the process of making games than a more detailed technical overview.

> the core techs for HTML5 gaming aren't quite from what I can tell. WebGL and the Audio APIs in particular seem on shaky ground for the moment... it seems there are still rather major security and performance problems to deal with.

The alleged WebGL security issues are mostly solved now. WebGL has about as much security issues as anything to deal with graphics, a computer can crash because of CSS 3D transitions almost as much as it can because of WebGL.

As for Audio APIs, open security issues are mostly to do with user permissions. The worst thing you can do currently is break the ears of the user and make the application unresponsive. You can do as much without audio APIs: var a = new Audio(); a.src = 'noise.mp3'; a.play; while(1);

As for the maturity of the APIs, WebGL offers most of the capabilities of OpenGL, except for a few quirks like Texture1D not being supported, more strict limits in construct sizes and referencing arrays (for some types you need to use constant value indices, unlike in normal OpenGL).

Audio APIs are in a weird spot now, we have two proposals, one from Google and one from Mozilla. Both have their virtues, and they offer solutions to a bit different problems. But at W3C Audio WG we are working on making these things better, so that eventually we'll get audio APIs across all browsers.

> Most worrying however is the utter lack of any non-TCP networking in the browser, not even at the specification-proposal stages. Any sort of real time multiplayer really kinda needs UDP to work efficiently. P2P is also fairly important for certain applications and is in a similar state.

This is indeed a huge weak spot, but it's hard to achieve securely. Making solid APIs for P2P connections, spanning more use cases than video streams would unleash open a galore of new doors, so I do hope WebRTC will bring forth a good solution.

Re: HTML5 as a gaming platform

#14
post #11

Earlier quoted context omitted.

Phones need serious improvement to run these kinds of games anyway, we're probably looking at at least half the time it's going to take for these games to run with the web technology stack on the mobile to get it running even natively on the mobile. So for mobile, the wait is on, no matter what. It's going to take a while, but our toolkits need sharpening as well, so I'm not expecting a non-trivial web game to emerge…

A cross between simulation and RTS game. You're supposed to build up a colony and manage your society. The details are not too abstract, as all units you see will have individual names and the details of your infrastructure are pipes, conveyor belts, workshops, electrical lines, generators, and so on. You could say it's a "dwarffortress" except the details are totally different. For example, chopping down trees will…

Make sure to make a fuzz about it when it's ready to be played, I sure have to give it a shot!

Re: HTML5 as a gaming platform

#15

Personally I'd love to see more of this. I've been casually trying to help HTML5 Canvas as a gaming platform get off the ground for some time now. It's sort of a hobby at this point. I've answered a little over 10% of all Canvas questions ever asked on StackOverflow, which has lead me to writing a few tutorials on Canvas-related issues that people come up with. As a current side project I'm developing a set of HTML5…

Performance, yes, that is probably the biggest issue you are going to have with HTML5 in my experience.

I'm doing nothing more than pushing a set of tiles around a canvas element, and there are irregular hiccups where the animation loop (a simple setInterval callback) stops for a frame before starting back up again.

Granted, the stuff I'm doing is pretty simplistic, and I haven't tried to optimize for performance yet (or code around the stutters), but it's not an encouraging place to start from as a hobby game developer, let alone someone trying to make a living from it.

Re: HTML5 as a gaming platform

#16
I'm a rank amateur when it comes to game development, however I've written a few games, and have been working on one in HTML5 (in addition to having made a few 'test games', which were really just proofs of concept). I've found that the HTML5 Canvas has been great for my needs. It's certainly not at the point where it can compete with desktop games, but trying to make it do that seems absurd (is the browser really the right place for games like Mass Effect?)

That said, writing games in HTML5 is much harder than on other platforms, for example:

A) As the post mentions, the Audio APIs are embarrassingly bad. There is, as far as I can tell, no way which you can cause a sound to play (programmatically, I've never really tried to use the actual element) in a cross-browser compatible way without having to manually code for the different APIs. One would think that Audio, one of the poster children for HTML5 would have some standardization.

B) Chrome/Safari (and probably IE too) refuse to rescale anything without interpolating it (e.g. no pixelated effects without manually resizing the imagedata). Firefox offers a mozImageSmoothingEnabled property on the canvas element which allows for effects like this, but unless you're developing solely for Firefox, you're out of luck.

C) If you have a large enough canvas and you get the imagedata for it, Firefox can throw an exception because it's bigger than the largest allowed array. This can be solved by manipulating the image data on a smaller canvas and drawing that canvas on a bigger one, but it's still an annoying inconsistency.

Those last two, while minor quibbles, are indicative of the kinds of problems I've run into several times while working with HTML5. Each browser handles everything in a different way, and as far as I can tell, none of them care how the others work. This means that you must test every piece of code you write on every browser you wish to support. Obviously, this has a significant negative impact on development time, and can make some games prohibitively difficult.

On the other hand, there are platforms like Java or Flash (or Unity, so I've heard), where you can write once and expect it to work identically everywhere (even on out of date browsers). That must be nice.

Re: HTML5 as a gaming platform

#17
"So what's in common with these two games? They're both originally mobile games." (Emphasis mine.)

The sad part is that once converted to HTML5 these games won't be able to run on many (most?) mobile devices. Current mobile browsers are too slow or non-standard to run HTML5 based games. The exception is iOS 5 powered devices (iPhone/iPad) since the browser now includes hardware acceleration for both HTML5 canvas and CSS3 animation transforms.

For more details, see Spaceport.io's recent HTML5 animation performance tests: http://spaceport.io/spaceport_perfmarks_report_2012_3.pdf

Re: HTML5 as a gaming platform

#18
post #16

I'm a rank amateur when it comes to game development, however I've written a few games, and have been working on one in HTML5 (in addition to having made a few 'test games', which were really just proofs of concept). I've found that the HTML5 Canvas has been great for my needs. It's certainly not at the point where it can compete with desktop games, but trying to make it do that seems absurd (is the browser really th…

> There is, as far as I can tell, no way which you can cause a sound to play (programmatically)

I suggest you give my audiolib.js ( https://github.com/jussi-kalliokoski/audiolib.js ) and sink.js ( https://github.com/jussi-kalliokoski/sink.js ) a shot, they're designed to abstract away the differences between the "competing" Audio APIs, allowing you programmatic access to as deep as the sample level and providing abstractions such as filters, reverbs, delays, etc. For browsers with no Advanced Audio API, there's an inferior fallback using the elements.

> On the other hand, there are platforms like Java or Flash (or Unity, so I've heard), where you can write once and expect it to work identically everywhere (even on out of date browsers). That must be nice.

I've heard good things about Unity, and it seems to be a great toolkit for game development. However, write once, works everywhere is a pipedream, really. Even for something as simple as a document website, taking all the possible input methods and screen resolutions, etc. into account is hard work. This is where the mentioned technologies fall short and the web stack shines. If you really need to care about that, it's up to you.

I agree with your sentiments about the B and C to great extent. Also the performance of imagedata is absurdly bad. The interpolation issue is, well... I think I'll write another blog post soon, about how ZOH interpolation may sometimes be the best quality option.

Re: HTML5 as a gaming platform

#19
I've been playing around with Canvas2D and now WebGL (via ThreeJS) for a little over a year for my pet project 88etag (https://github.com/lucaspiller/88etag). It's a clone of an old 2D space RTS I used to waste many hours playing.

Personally the biggest issues I've come across is the poor performance of the interface code between Javascript and the rendering layer. If anyone has any tips for how to avoid these they would be highly appreciated.

Re: HTML5 as a gaming platform

#20

"So what's in common with these two games? They're both originally mobile games." (Emphasis mine.) The sad part is that once converted to HTML5 these games won't be able to run on many (most?) mobile devices. Current mobile browsers are too slow or non-standard to run HTML5 based games. The exception is iOS 5 powered devices (iPhone/iPad) since the browser now includes hardware acceleration for both HTML5 canvas and…

Current mobile browsers, yes, very much so.

But I think Chrome for Android 4 (which I believe will replace stock Android browser eventually), IE10 for Windows 8 phones / tablets, and Firefox on B2G will change this. I've seen B2G already running mobile web games smoothly on Android hardware.

Post reply on HN