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.

Game Development With HTML5

65,389 views

Published on

Game development using HTML5 technologies presentation, May 2010.

This lecture was given by Gil Megidish at AlphaGeeks #6 meetup in Tel Aviv, Israel.

The talk begins with some review of the game graphics techniques, and how you can achieve these with today's browsers and client side code.

4 demos were presented: sprites with canvas (luigi), framebuffer access (apple2 emulator), primitives and polygons (another world js) and image modifiers (droste effect.)

The lecture was given in Hebrew, ppt is English.

Published in: Technology
  • There is a useful site for you that will help you to write a perfect and valuable essay and so on. Check out, please ⇒ www.WritePaper.info ⇐
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THE BOOK INTO AVAILABLE FORMAT (New Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THE can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THE is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBOOK .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, CookBOOK, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, EBOOK, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THE Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THE the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THE Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THE BOOK INTO AVAILABLE FORMAT (New Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THE can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THE is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBOOK .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, CookBOOK, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, EBOOK, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THE Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THE the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THE Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THE BOOK INTO AVAILABLE FORMAT (New Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THE can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THE is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBOOK .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, CookBOOK, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, EBOOK, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THE Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THE the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THE Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THE BOOK INTO AVAILABLE FORMAT (New Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THE can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THE is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBOOK .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, CookBOOK, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, EBOOK, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THE Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THE the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THE Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Game Development With HTML5

  1. 1. <games /> Gil Megidish [email_address]
  2. 2. And I love writing / rewriting / reverse engineering games
  3. 4. What The Heck is HTML5 Canvas Video Audio Web Sockets Web Storage Web Worker Web Database Selectors Validation File API Semantic Elements
  4. 5. Man will make it to Mars before HTML5 is on my Firefox! W3C’s ETA: Year 2022
  5. 6. Games + Javascript? = wtf
  6. 7. Why Bother With Javascript? <ul><li>Fun to develop </li></ul><ul><ul><li>Hacker’s spielplatz! </li></ul></ul><ul><li>Fast deployment </li></ul><ul><ul><li>Serve static files </li></ul></ul><ul><li>Easy to debug </li></ul><ul><ul><li>alert(), firebug.. Still better than the alternative! </li></ul></ul><ul><li>Open source and free tools </li></ul><ul><ul><li>Notepad, vi, emacs </li></ul></ul><ul><li>B.Y.O. framework </li></ul><ul><ul><li>jQuery? </li></ul></ul>spielplatz
  7. 8. But Why REALLY? <ul><li>Has been around for ages </li></ul><ul><li>Won’t go away any time soon </li></ul><ul><li>Wide support: </li></ul><ul><ul><li>Web browsers </li></ul></ul><ul><ul><li>Mobile devices </li></ul></ul><ul><ul><li>Facebook applications </li></ul></ul><ul><ul><li>On a rocket near you </li></ul></ul>
  8. 9. Anatomy of a Game LOGIC GRAPHICS INPUT SOUND MUSIC MULTIPLAYER GAME ASSETS
  9. 10. Anatomy of a Game LOGIC GRAPHICS INPUT SOUND MUSIC MULTIPLAYER GAME ASSETS javascript code <canvas> onkeydown, onmousedown <audio> <audio> ajax, WebSocket Images, Audio, Video and Binary supported by browsers
  10. 11. Graphics
  11. 12. Framebuffer (raw) 0,0 0,1 0,2 0,3 0,4 0,5 0,6 0,7 0,x 1,0 1,1 1,2 1,3 1,4 1,5 1,6 1,7 1,x y,0 y,1 y,2 y,3 y,4 y,5 y,6 y,7 y,x x y … … … . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  12. 14. Tile + Sprite Memory
  13. 16. Scene Graph Placeholder For Future Presentation
  14. 18. Canvas is King
  15. 19. DEMO TIME!
  16. 20. Three Demos To Rule Them All Framebuffer demo http://www.megidish.net/apple2js/ Sprites demo http://www.megidish.net/alphageeks6/luigi/ Vector graphics demo http://www.megidish.net/awjs/
  17. 21. Catch me a canvas <ul><li><canvas id=“graphics” width=“640” height=“480”> </li></ul><ul><li>Guru Meditation: No canvas supported! </li></ul><ul><li></canvas> </li></ul><ul><li>var canvas = document.getElementById(“graphics”); </li></ul><ul><li>var context = canvas.getContext(“2d”); </li></ul>
  18. 23. Drawing Primitives <ul><li>ctx.fillStyle = “#c80000&quot;; </li></ul><ul><li>ctx.fillRect (10, 10, 55, 50); </li></ul><ul><li>ctx.fillStyle = &quot;rgba(0, 0, 200, 0.5)&quot;; </li></ul><ul><li>ctx.fillRect (30, 30, 55, 50); </li></ul>Other drawing methods: arc, bezierCurve, lineTo, quadraticCurve, rect, stroke, fillText, strokeText, beginPath/closePath and fill
  19. 24. (but who needs that ?)
  20. 25. Drawing Images <ul><li>var sprite = new Image(); </li></ul><ul><li>sprite.src = “luigi.png”; </li></ul><ul><li>var x = 0, y = 0; </li></ul><ul><li>ctx.drawImage(sprite, x, y); </li></ul>
  21. 26. Drawing Images 2 <ul><li>var spritemap = new Image(); </li></ul><ul><li>spritemap.src = “sprite-map.png”; </li></ul><ul><li>ctx.drawImage( </li></ul><ul><li>spritemap, </li></ul><ul><li>sx, sy, </li></ul><ul><li>sw, sh, </li></ul><ul><li>dx, dy, </li></ul><ul><li>dw, dh </li></ul><ul><li>); </li></ul>Sprite maps save loading time by fewer requests and better compression. drawImage() also provides scaling and cropping.
  22. 27. Going Crazy With Images // context state checkpoint ctx.save(); ctx.translate(0, 80); ctx.rotate(-45 * Math.PI / 180.0); ctx.scale(3.0, 1.0); ctx.drawImage(luigi, 0, 0); // revert all context changes ctx.restore();
  23. 28. Accessing Pixels <ul><li>var block = ctx.getImageData(sx, sy, sw, sh); </li></ul><ul><li>block = { </li></ul><ul><li>width: width in pixels, </li></ul><ul><li>height: height in pixels, </li></ul><ul><li>data: array of 4*width*height bytes </li></ul><ul><li>}; </li></ul><ul><li>Alternatively: ctx.createImageData(w, h); </li></ul>
  24. 29. Accessing Pixels <ul><li>var block = ctx.getImageData(0, 0, canvas.width/2, canvas.height); </li></ul><ul><li>for (var y=0; y<block.height; y++) </li></ul><ul><li>{ </li></ul><ul><li>for (var x=0; x<block.width; x++) </li></ul><ul><li>{ </li></ul><ul><li>block.data[(y*block.width+x)*4+0] ^= 0xff; </li></ul><ul><li>block.data[(y*block.width+x)*4+1] ^= 0xff; </li></ul><ul><li>block.data[(y*block.width+x)*4+2] ^= 0xff; </li></ul><ul><li>} </li></ul><ul><li>} </li></ul><ul><li>ctx.putImageData(block, 0, 0); </li></ul>
  25. 30. Why Access Pixels ? Complicated things impossible without putImageData() Read image pixels getImageData combined with primitive drawing = save image to disk! These examples are available to http://www.chromeexperiments.com/
  26. 31. The Jazz Singer
  27. 32. Let There Be Sound! <ul><li><audio id=“sfx001” src=“/mp3/boom.mp3”></audio> </li></ul><ul><li>$(“sfx001”).play(); </li></ul>
  28. 33. Let There Be Sound! <ul><li><audio id=“sfx001” src=“/mp3/boom.mp3”></audio> </li></ul><ul><li>$(“sfx001”).play(); </li></ul><ul><li>Other methods: </li></ul><ul><li>$(“sfx001”).pause(); </li></ul><ul><li>Other attributes: </li></ul><ul><li>$(“sfx001”).currentTime = 35.0; </li></ul><ul><li>$(“sfx001”).volume = 0.5; </li></ul><ul><li>$(“sfx001”).duration (read only) </li></ul>
  29. 34. Putting It All Together
  30. 35. Typical Game Loop <ul><li>function gameTick() </li></ul><ul><li>{ </li></ul><ul><li>processKeyboard(); </li></ul><ul><li>moveEnemies(); </li></ul><ul><li>drawGraphics(); </li></ul><ul><li>updateAudio(); </li></ul><ul><li>} </li></ul><ul><li>var fps = 60; </li></ul><ul><li>setInterval(gameTick, 1000 / fps); </li></ul>
  31. 36. The Future is Upon Us!
  32. 37. Quake2 HTML5
  33. 38. What’s Coming Up Next <ul><li>WebGL </li></ul><ul><ul><li>OpenGL interface for Javascript </li></ul></ul><ul><ul><li>As of May, 2010: good luck finding a stable browser! </li></ul></ul><ul><li>WebSocket </li></ul><ul><ul><li>UDP and nonblocking transport layer </li></ul></ul><ul><ul><li>Not there yet! (KAAZING?) </li></ul></ul><ul><li>WebStorage </li></ul><ul><ul><li>Save games? </li></ul></ul>
  34. 39. Code Like It’s 2020! ftw! ‘ s Blackberry coming June 1 st !
  35. 40. Q&A
  36. 41. Q&A <ul><li>Yes! You can use <canvas> in Internet Explorer 6? </li></ul><ul><li><!--[if IE]> </li></ul><ul><li><script type=&quot;text/javascript“ src=&quot;/js/excanvas.js&quot;> </li></ul><ul><li></script> </li></ul><ul><li><![endif]--> </li></ul><ul><li>PS. Remember to upgrade your mother’s IE! </li></ul>
  37. 42. Links! <ul><li>Chrome Experiments: Not Your Momma’s JS </li></ul><ul><ul><li>http://www.chromeexperiments.com </li></ul></ul><ul><li>Appcelerator’s Titanium </li></ul><ul><ul><li>www.appcelerator.com </li></ul></ul><ul><li>Box 2D: real time physics for JS games </li></ul><ul><ul><li>http://box2d-js.sourceforge.net/index2.html </li></ul></ul><ul><li>Mozilla’s Canvas tutorial </li></ul><ul><ul><li>https:// developer.mozilla.org/en/Canvas_tutorial </li></ul></ul>
  38. 44. GO MAKE GAMES! http://www.megidish.net

×