Your SlideShare is downloading. ×
0
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Game Development With HTML5
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Game Development With HTML5

61,349

Published on

Game development using HTML5 technologies presentation, May 2010. …

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
8 Comments
56 Likes
Statistics
Notes
  • no more need for flash? an understandable first impression but please, by all means, if you'd prefer to indulge the tyranny of javascript over the orders of magnitude more pleasant to program in Actionscript 3... be my guest :) In all seriousness though, I think flash is going to remain around, particularly in games development for years to come. Just check out the flash portals. They're thriving. More new content than ever. Adobe has released Molehill. Unity3D compiles to Flash swf format now. The Epic UDK produces flash. Some of the bets as3 books have only recently been released. There has been very substantial flash as3 publishing activity actually lately. I think that the fundamental confusion here is that Adobe has handed off the Flex SDK to Apache to do with as they will. This by no means whatsoever constitutes a plan to abandon the flash as3 platform. In fact, it's oly just peaked. With Starling and Stage3D and Molehill, 3rd party tools like Aweay3d 4Gold... sky is the limit!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • @OctavOnu it's called The Incredible Machine. Was my favourite game when I was a kid.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • ho my God....guru meditation... ;O) Tnx, nice slide!!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • @OctavOnu That's The Incredible Machine. Thanks for the comments :)
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • great overview..
    can you please let me know the name of the game posted in slide no 34 ?
    I ve been looking for it for so many time!
    Thank you very much
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
61,349
On Slideshare
0
From Embeds
0
Number of Embeds
17
Actions
Shares
0
Downloads
1,455
Comments
8
Likes
56
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. <games /> Gil Megidish [email_address]
  • 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
  • 5. Man will make it to Mars before HTML5 is on my Firefox! W3C’s ETA: Year 2022
  • 6. Games + Javascript? = wtf
  • 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
  • 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>
  • 9. Anatomy of a Game LOGIC GRAPHICS INPUT SOUND MUSIC MULTIPLAYER GAME ASSETS
  • 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
  • 11. Graphics
  • 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 … … … . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  • 13.  
  • 14. Tile + Sprite Memory
  • 15.  
  • 16. Scene Graph Placeholder For Future Presentation
  • 17.  
  • 18. Canvas is King
  • 19. DEMO TIME!
  • 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/
  • 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>
  • 22.  
  • 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
  • 24. (but who needs that ?)
  • 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>
  • 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.
  • 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();
  • 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>
  • 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>
  • 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/
  • 31. The Jazz Singer
  • 32. Let There Be Sound! <ul><li><audio id=“sfx001” src=“/mp3/boom.mp3”></audio> </li></ul><ul><li>$(“sfx001”).play(); </li></ul>
  • 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>
  • 34. Putting It All Together
  • 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>
  • 36. The Future is Upon Us!
  • 37. Quake2 HTML5
  • 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>
  • 39. Code Like It’s 2020! ftw! ‘ s Blackberry coming June 1 st !
  • 40. Q&A
  • 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>
  • 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>
  • 43.  
  • 44. GO MAKE GAMES! http://www.megidish.net

×