News for hackers. Stuff that matters.
Re:Making Sprite-based Games with Canvas by SeanDav on Tuesday March 19, 2013 @02:30PM (#5402698)
I have very little knowledge in this domain, but why do so few of these demos ever have sound? Is there something lacking with canvas and sound/music?
Re:Making Sprite-based Games with Canvas by zacksjoden on Tuesday March 19, 2013 @02:35PM (#5402725)
I haven't followed html5 development too closely, but audio support in current browsers hasn't been uniform. I'm guessing the lack of one size fits all for audio in browsers is why.

http://en.wikipedia.org/wiki/HTML5_Audio

edit: I'd also guess because audio is hard and that it is probably easier to make graphics and gaming logic than making sounds/music properly.

Re:Making Sprite-based Games with Canvas by dmiladinov on Tuesday March 19, 2013 @02:36PM (#5402732)
Probably because that's harder or outside of the scope of a demo. The first search result for "html5 games sound music" was this case study: http://www.html5rocks.com/en/tutorials/webaudio/fieldrunners...

From the first paragraph:

"Fieldrunners is an award-winning tower-defense style game that was originally released for iPhone in 2008. Since then it has been ported to many other platforms. One of the most recent platforms was the Chrome browser in October 2011. One of the challenges of porting Fieldrunners to an HTML5 platform was how to play sound."

Re:Making Sprite-based Games with Canvas by jlongster on Tuesday March 19, 2013 @02:45PM (#5402782)
I discussed it briefly near the end of the article under "Adding Sounds". The main reason this article doesn't do it is because it's focusing on rendering with canvas, and there's already a lot of information for beginners to go through there.

I plan on writing a followup to include sound, though, or possible extending this article.

What the other comments say is true, also. It's not extremely straightforward. The state of APIs on the web is very mixed, but I think in a year or so the Web Audio API will in most places.

Re:Making Sprite-based Games with Canvas by tomjen3 on Tuesday March 19, 2013 @03:02PM (#5402879)
Canvas doesn't have any kind of support for playing music, but there is a (flash) based sound manager that works everywhere and Chrome has some facility for playing sound too.

However making music is an art not all programmers have mastered, so most would likely skip that step.

Re:Making Sprite-based Games with Canvas by city41 on Tuesday March 19, 2013 @06:12PM (#5403954)
All modern browsers support the HTML5 audio tag.
Re:Making Sprite-based Games with Canvas by tomjen3 on Wednesday March 20, 2013 @01:42PM (#5408863)
Yeah but that isn't really good enough to play sounds in (for a game).
Re:Making Sprite-based Games with Canvas by city41 on Friday March 22, 2013 @01:46PM (#5424403)
I disagree, it's not the best, but it's decent enough for most games. Most HTML5 game engines use the audio tag. My game uses a good amount of sound effects and background music just fine with the audio tag: http://cityfortyone-mattgreer.dotcloud.com/dragonPlunder/