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

64,952 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
  • DOWNLOAD FULL BOOKS, INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y3nhqquc } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y3nhqquc } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y3nhqquc } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y3nhqquc } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y3nhqquc } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y3nhqquc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD FULL. BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD FULL. BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • For Game Development Certification Courses Visit http://www.todaycourses.com
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Njce! Thanks for sharing.
       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

×