Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Open Web Games with HTML5 & JavaScript


Published on

In this talk Rob will highlight the key technologies and events that are going to affect open Web game development in the near future. He will also demo some of these new technologies and show how easy it is to share your game and make money from it using the open and distributed Mozilla Labs Apps project.

Published in: Technology, Design
  • Be the first to comment

Open Web Games with HTML5 & JavaScript

  1. 1. ES M t A rip G B avaSc E W L5 & J es EN TM bH aw k OP ing H Ro s UHi, I’m Rob Hawkes and I’m here today to talk about creating games on the open Web usingHTML5 and JavaScript.
  2. 2. I work at Mozilla, a non-profit fighting for a better Web. The guys who make Firefox.Unsure about how much I like Mozilla? This here is a beautiful chicken and leek pie with extraFirefox goodness.It was made by my talented girlfriend and it was delicious.
  3. 3. My official job title is Technical Evangelist, but I prefer what it says on my business card.Part of my job is to engage with developers like you and I about cool new technologies on theWeb.And for those of you with no idea of what a rawket is, I made a multiplayer game calledRawkets in which players fly around in little rockets and shoot each other in the face with thelatest Web technologies. It’s quite addictive!
  4. 4. I’m not sure how much time we’ll have for questions at the end, but feel free to grab me inperson after the talk or on Twitter.These slides will go online after this talk and they’ll be available from my personal website.I’ll put all the details up at the end.
  5. 5. Before we move on I just have a quick disclaimer.This whole talk is about HTML5 and JavaScript as technologies for the creation of games.They’re technologies that are intrinsically linked to each other by nature, but saying HTML5and JavaScript every single time makes my head hurt.So instead I’ll just be saying HTML5.Just bear in mind that whenever I mention HTML5 I’m also referring to JavaScript as well.
  6. 6. So let’s go back in time for a moment.Now I don’t actually remember when I first started playing computer games, although I knowthat I started with consoles.
  7. 7. My first experience was with the ZX Spectrum and its amazing noises and epic loading times,which I sorely miss…
  8. 8. Then there was the SNES, which really got me addicted to gaming.Although it turns out my SNES was stolen when I was a kid. I did wonder where it went…
  9. 9. My parents replaced it with the Megadrive which, although not quite as awesome, was just asfun.From there it has been a constant stream of consoles, each smashing the performance andfunctionality of its predecessor.The N64, the Gamecube, the Dreamcast, the Playstation, the xBox.You get the idea…
  10. 10. And spread throughout that time I dabbled in PC gaming, starting with games like Sim City…
  11. 11. And Megarace.Who remembers this one?
  12. 12. And playing multiplayer Doom at my Dad’s Internet cafe.What I’m getting at here is that gaming has been a big part of my life growing up, as it hasbeen with a lot of other people as well.They’re fun to play, and they’re surprisingly fun to make.
  13. 13. ow is n e cool tim thing he om e T do fs ol resh ThToday we’re now on the threshold of something cool; being able to create awesome andaddictive games with nothing more than the technologies that we normally use to makewebsites, namely HTML5 and JavaScript.Since I began developing on the Web I really can’t remember a time when so many people areworking together to achieve something like this.
  14. 14. n ts e ve ng ble am i ota L5g N HTM in s-on going nt rta po ImRecently there have been some particularly notable events surrounding HTML5 gaming.
  15. 15. ns itio uis up Acq g boug ht in be es gin e en am 5g TML HThe acquisition of HTML5 gaming engines by large companies.Like Aves being bought by Zynga and Rocket Engine bought by Disney.
  16. 16. n t e itm ted ecru an R arew ers velop e de am L5g HTMThe recent recruitment of HTML5 games developers for well-known gaming companies, likeCrytek.
  17. 17. in g nd Fu eers ion thep in sting InveThe huge amounts of funding being made available to games that help prove the Web as agaming platform.Like the Game Lab from Bocoup and Atari’s general sponsorship of HTML5 games.
  18. 18. ce s n re mes nfe ga Co L5 HTM of ture fu the ssing cu DisThe two large-scale HTML5 gaming conferences last year; onGameStart in Poland and NewGame in San Francisco.Each attended by hundreds of game and Web developers alike.And rooms like this at other events are becoming much more common.
  19. 19. n t e m es olve am v in HTML 5g ser for row e tech B th ing rovid PThe investing of time and resources by Google, Mozilla and Opera into the creation oftechnologies and services for the benefit of gaming on the open Web.Some of which we’ll be looking at in a moment.
  20. 20. nt e m ce o lve an inv rfo rm ok ing pe bo tter ace Be FThe involvement of Facebook in HTML5 gaming performance.
  21. 21. e s g a m iO S ap ab le h it than c ing ore ort L 5ism P HTM wing ShoAnd the recent port to HTML5 of massively successful iOS games like Angry Birds,Fieldrunners, and Cut The Rope.http://chrome.angrybirds.comhttp://fieldrunnershtml5.appspot.com
  22. 22. es g a m ing ples ist exam Ex he be st ft eo SomNow there aren’t a huge amount of HTML5 games just yet, although that number is growingevery day.In any case I thought I’d show you a selection of my favourites; some full blown games,others demos of the technologies available to us.
  23. 23. Quake IIMultiplayer Quake II remake with Google GWT (Google Web Toolkit).
  24. 24. Minecraftian worldsMinecraft map viewer, using WebGL.This isn’t really a game, but it’s not a long way from becoming a JavaScript port of Minecraft.
  25. 25. Minecraftian worldsWebCraft is an attempt at a port of Minecraft Classic.
  26. 26. Angry BirdsThere isn’t much to say about Angry Birds really, most of you probably know about it.The HTML5 version uses WebGL for accelerated 2D graphics.
  27. 27. FieldrunnersFieldrunners was ported from iOS to HTML5 by Bocoup.Like Angry Birds, it also uses WebGL for accelerated 2D graphics.
  28. 28. Cut The RopeCut The Rope was also ported from iOS to HTML5.
  29. 29. BejeweledBejeweled is a massively popular game on a whole variety of platforms.Popcap recently released a purely HTML5 version that uses WebGL for accelerated 2Dgraphics.
  30. 30. Created by Phil Banks (@emirpprime)It’s clear that HTML5 is something that is really becoming a contender for games on the Web.
  31. 31. ipt Scr Java about? 5 & fuss L M at is all the HT h WBut why is it important?Well to put it simply, HTML5 & JavaScript are the underlying technologies behind everythingrelated to the future of the Web.Pretty much every new technology that is coming out within the browser-space is connectedto HTML5 and JavaScript in some way.And what’s great is that every major browser has invested in them, so they won’t be goinganywhere any time soon.But there’s more to it than that.
  32. 32. ies log n o de ch source te he co en t Op nv iew ca yone AnThey are open technologies.Anyone can get involved in their creation; through browser developers like Mozilla, orthrough standards organisations like the W3C.Not long ago I was in a W3C meeting to explore what is needed for making games with thesetechnologies. What was cool was that anyone was allowed to take part; which includedeveryday developers, employees of major browsers, and games companies.Also, these technologies are open in that anyone can view the resulting code that is usedwithin Web pages, which is a fantastic way of learning.
  33. 33. ie s lo g n o ith e c h lop w e t de ve Fre ree to se.F u to FreeThey are free technologies.Anyone can use these technologies without having to pay anything, both for using thetechnology and developing with it.This is unlike closed environments like Flash where you have to pay to use official codeeditors and production environments.
  34. 34. less - in ware lug P soft rty d-pa thir on ce elian orer NomThey are technologies baked directly into the browser, which means no more plugins!No longer do you have to rely on users having third-party software installed to use richmedia.
  35. 35. io n t ila ing m p st co nd te No en ta pm evelo ithd e w tim ve SaHTML5 and JavaScript dont require compiling, so development and testing can be extremelyrapid.These technologies allow for quickly hacking stuff together to experiment then tidying thingsup later.It’s this rapid nature of JavaScript and HTML5 that make them so fun to develop with.
  36. 36. b le e ra s rop rm Inte ss pla tfo cro orka ttow buil are ey ThThese technologies are built to work across platforms; whether that’s desktop, mobile, TV, oranything else!This makes it great to develop this way because you can be sure that it will work on anyplatform that has support.
  37. 37. o rt p p s u ed se r up po rt ro w ares -b ures ross ajor feat C m ost MAs with any technology on the Web it’s important that you can use it across all the majorbrowsers.Fortunately the bigger features of HTML5 like video and audio are supported by all the majorbrowsers, with some of the newer and smaller features getting better support as time goeson.The situation isn’t perfect but we’re definitely in a position where these technologies can nowbe used in production.There’s a fantastic website called Can I Use? which lets you know what browsers support eachtechnology.
  38. 38. But it’s not all rosy with HTML5.Why might you not want to use it?Here are just two of the major issues that are floating around right now.
  39. 39. ility at ib m p ryt hing co ve ull pp orte F ers su rows ll b ta NoNot every browser supports every part of HTML5.For example, canvas isn’t supported out of the box by any IE below 9. Although, you can useExplorerCanvas to replicate canvas functionality, but it’s not ideal and as doesn’t perform aswell.WebSockets is only support in IE10 and has poor support on Android. But again, you can fakethis by using Flash for the sockets, like with Socket.IO.WebGL also has patchy support with absolutely no support in IE, and Safari and Operarequiring a development build.
  40. 40. RM o D N ologies echn eset th st again goes ItIf you need DRM or have a burning desire to hide absolutely everything about your code.Remember, the code isn’t compiled, so where would the DRM go? The beauty of Webtechnologies is that they can be read as plain text by simply viewing the page source.However, DRM isnt bulletproof in itself and you can still crack into things like Flash.You can obfuscate and minify your code if you think it will help, but even this can be workedaround with relative ease.
  41. 41. g y o lo chn es Te L5g am TM fH so cene s he dt hin BeThere are a few key technologies that are involved in the development of HTML5 games.Here are some of my favourites.
  42. 42. vas an C tfo rm pla ics raph g 2DCanvas is a 2D graphics platform that uses both HTML5 and JavaScript.It’s quite amazing what can be done with such simple drawing and image manipulation tools.
  43. 43. Silk is a stunning example of what can be achieved by combining the simple drawing toolsavailable in canvas.
  44. 44. GL eb W form lat sp hic grap 3DWebGL brings the ability to provide advanced 3D graphics directly within the browser.
  45. 45. HelloRacer is a little game that lets you drive a Formula One car around your browser. It’s abeautiful example of WebGL in action.
  46. 46. Rome is a music video created with WebGL. It’s an amazing example of what the technologycan achieve in a real-world situation given a large team.
  47. 47. This is a rather freaky example of how interesting WebGL is.It’s a demo that shows just how realistic WebGL can render materials, like skin. This isn’tmuch unlike the quality of modern games consoles!
  48. 48. d io a u L5 usic TM nd m H grou ck ba nd ctsa effe nd SouHTML5 audio allows for plugin-less game sound effects and background music.Audio data APIs implemented by Mozilla and Google allow for manipulation of audio andmuch more fine-grained control.
  49. 49. This is something I made especially for the ASSEMBLY 2011 event in Finland.It’s an audio visualiser that uses WebGL and the HTML5 Audio Data API.
  50. 50. e ts ock bS ation e W omm un ic yerc ltipla MuWebSockets can be used for the real-time communication between a player and the gameserver.With WebSockets you can create multiplayer games with relative ease.
  51. 51. e.js od N cation uni m com rk etwo dn an logic e GamNode is often used as a multiplayer game server, controlling the logic and handling theWebSockets connections to the players.It can be used for player authentication and the storage of data so gameplay can persist overmultiple game sessions.This is all made relatively easy with great third-party modules, like Socket.IO for WebSockets,and others that handle Redis and MongoDB for storage, for example.
  52. 52. ge ra to vice cal s r de Lo pla ye he t on ta da ng StoriMethods like the application cache, Local Storage, and IndexedDB are great for storing datalocally on the player device.This way you can cache game data and allow the game to pick up where the player left off.
  53. 53. PI n A re e ul Sc we rf ull et po F im ple ,y SThe Full Screen API allows you to expand any HTML element to fill the users screen, even ifthe browser isn’t running full screen itself.The Mozilla implementation is not perfect yet because you can’t use the whole keyboard infull-screen mode without a message popping up, but it’s in the latest Nightly builds andworks in all other respects.
  54. 54. P I d A p a eb me he W Ga et ot ol ns co he gt gin BrinThe Gamepad API is one of the major improvements to input that is coming.Both Mozilla and Google are working an an implementation of this and there is actually anexperimental build of Firefox available to the public that has it working. The API is also in theCanary build of Chrome.What I find most interesting about the Gamepad API is that it might be just the thing we needto finally justify HTML5 gaming on a TV or console.Who wants to use a keyboard and mouse while sitting on the sofa?
  55. 55. I’d like to show you a quick demo of the Gamepad API working in Firefox Nightly.In this example I’ve connected my xBox 360 controller to my Mac, but I could also use a PS3controller or practically any other USB controller.
  56. 56. This is another little demo that I put together to show off the Gamepad API implemented inmy game Rawkets.
  57. 57. P I A o ck ace L use no ne pl Mo rso ri cu he gt ockin LThe Mouse Lock API is an attempt at improving the mouse as an input device.It would be used in situations like games and 3D visualisations where the mouse positionrotates or moves you around a 3D space.As it stands there’d still be a cursor moving around the screen causing all sorts of troublewhen you want to click on something in your game.With the new API you can lock your mouse position and stop it from getting in the way andbeing a nuisance.Both Google and Mozilla are working on an implementation of this right now, it’s available ina custom build of Firefox.
  58. 58. n s tio plica bsite ap yw e eb ta fanc W ot jus NThe concept of Web apps is something that is gaining a lot of traction at the moment.HTML5 games are effectively glorified Web apps.It’s no doubt this this traction is as a result of the success of native applications and gameson the desktop and mobile, particularly with iOS and Android.
  59. 59. Google are spending a lot of time on Web apps with the Chrome platform.
  60. 60. It’s something we’re also spending a lot of time on at Mozilla.Although we’re approaching things a little differently.We envisage Web apps to run on any device, any browser, and to be distributed through anystore or website.https://apps.mozillalabs.com
  61. 61. se ts a s line yw ay Off ern et an Int he st ed ne WhoOne of the main differences between Web apps and native apps is that native apps can be runoffline.New technologies like the application cache allow for a website or Web app to cachenecessary assets to that it can still run while offline.This includes things like JavaScript files, CSS and images.Combining this technique with intelligent use of things like local storage will allow your gameto continue working even if the Internet connection goes down. You just sync up all thechanges when it gets connected again.
  62. 62. nce erie exp scre en like ho me p- op or Ap eskt thed from ch un LaSomething that needs to be tackled with Web apps is how to make them feel like realapplications rather than websites.One way that is being considered is completely removing the browser chrome and runningthe application in it’s own window.This will effectively mean that you have full control of the app UI and it won’t look like it’sbeing run in a browser.
  63. 63. At Mozilla we call this WebRT, which stands for Web Run-Time.By using WebRT you can install a Web app directly into the OS just like you would a nativeapplication.The WebRT app will look and feel like a native application when launched but will actually berunning a browser rendering engine behind the scenes.This is an example of Rawkets running as a WebRT app with the Firefox rendering engine.Notice the lack of browser UI.
  64. 64. e s gin e n ay e m game st od Ga ML5 HT te CreaIf you haven’t already then I encourage you to give HTML5 game development a go.And you dont have to create an entire game infrastructure from scratch, you can use some ofthe existing engines that are proving popular.
  65. 65. Impact.I used this recently, and it’s really well made.The documentation is great and the author is active and very helpful.
  66. 66. Crafty.It’s a free engine and is doing much better than other free engines out there.
  67. 67. Isongenic Engine.One of the most promising engines out there today.Massively multiplayer networking built in, uses Node and MongoDB, and has canvas or DOM-based graphics.
  68. 68. tu re e fu ng Th gin ni be tthe is jus is ThIt’s still early days with HTML5 games.There are a few things that I’d like to see in the near future that will help.Need better ways to benchmark browser performance, network connections and operatingsystems specifically for games.Better HTML5 audio. Right now things can be a little tricky, the ideal situation would be tohave consistent support across browsers.Hardware accelerated canvas on Mac and mobile devices. This is a small ask but one that Ifeel will make all the difference.Better documentation for game development in JavaScript. This is something I’m working onwith Mozilla, but more documentation is needed in general. I’d love to see more gamedevelopers sharing their solutions to problems that they encountered during the creation oftheir games.
  69. 69. Rob Hawkes @robhawkes Personal website and blog RECENT PROJECTS MORE COOL STUFF Twitter sentiment analysis Rawket Scientist Delving into your soul Technical Evangelist at Mozilla HTML5 & WebSockets game Web development podcastGet in touch with me on Twitter: @robhawkesFollow my blog (Rawkes) to keep up to date with stuff that I’m working on: http://rawkes.comI’ve recently worked on a project that analyses sentiment on Twitter: is my multiplayer HTML5 and JavaScript game. Play it, it’s fun:
  70. 70. Ask MDN Coming back this year Web development topics ASKMDN Hand-picked experts Great discussions @ASKMDN & #ASKMDN ON TWITTERAnd lastly, I’d like to quickly mention Ask MDN which is a project that I’m working on atMozilla.The concept is simple; every so often we gather a bunch of experts to answer your questionsabout a particular topic.We’ve had a whole bunch of sessions to date and it’s going down really well. If you follow@AskMDN on Twitter you’ll be sure not to miss the next one when it starts again this year.
  71. 71. O U Y s? K tion N ues A yq TH An R b es wk es Ha wk ob ha ro @Thank you.If you have any questions feel free to grab me on Twitter (@robhawkes), or