GeeCON Prague 2014*
The moose likes HTML, CSS and JavaScript and the fly likes Beyond canvas, what are the most relevant HTML5 game related standards/technologies? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Beyond canvas, what are the most relevant HTML5 game related standards/technologies?" Watch "Beyond canvas, what are the most relevant HTML5 game related standards/technologies?" New topic
Author

Beyond canvas, what are the most relevant HTML5 game related standards/technologies?

Augusto Sellhorn
Ranch Hand

Joined: May 24, 2007
Posts: 57
A lot of focus on HTML5 when it comes to the web is focused on the low level (often 2d) graphic capabilities of the canvas component. I'm kind of wondering what else HTML5 brings to the table that is relevant to game programming in particular.

For example, HTML5 has the audio element, although I'm not sure what advantages it has over older methods of playing sounds.

I don't seen anything in HTML5 for things like basic geometry primitives, hit detection, animation (timers, easy in/out, etc) or support for gaming controllers (gamepads).

So some of these things are probably provided by js libraries/frameworks, but i'm wondering what other HTML5 components are there that are essential or more relevant to game programming, beyond basic drawing capabilities.

BTW - on hit detection, I was playing with some canvas stuff and the isPointInPath function to be puzzling. It works on a point hitting the current path, seems a bit useless. If you wanted to leverage it for graphical objects you create, you'd have to recreate the path (and not draw) on say a mouse click hit detection. Maybe I'm missing the point of this function ...
James Williams
author
Ranch Hand

Joined: Apr 18, 2009
Posts: 35
Augusto,

The audio element is ok for playing sounds. The key value in this is that it doesn't require a plugin. It's built into the browser. There are compatibility issues between browsers on what formats are supported. The three audio types that are supported in some shape or form are OGG(Ogg Vorbis), MP3, and WAV. The audio tag does have function called canPlayType that tells you if the specific browser might support a file type.



would tell you if the current browser supports MP3 files. Return values from canPlayType are "no", "probably", or "maybe".

CanIUse.com is another useful resource. If you want to use a library to test availability of HTML5 features, check out Modernizr.


Though not as widely supported, you should look into the WebAudio API. It picks up where the Audio tag leaves off like better support for volume/gain management, multiplexing sound, etc.

Re: collision detection and things like that, I don't believe that is a core concern for HTML5 implementers. Lots of libraries exist that do collision detection and response like bullet.js and jiglib.js.

Re: Gamepads: There is a specification API for gamepads and experimental support in Chrome and Firefox, more info here (https://wiki.mozilla.org/GamepadAPI).

Re: animation: Check the other threads in this forum where I talk about requestAnimationFrame, that facilitates core animation stuff but for easing functions/etc, you would have to do that yourself. One library that I like to use for easing stuff when I'm not using RaphaelJS(SVG and has built in easing funcs) is TridentJS(https://github.com/kirillcool/trident-js)
 
GeeCON Prague 2014
 
subject: Beyond canvas, what are the most relevant HTML5 game related standards/technologies?