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

More Related Content

PDF
한컴MDS_NVIDIA Jetson Platform
PDF
jQuery for beginners
PDF
Deep Dive async/await in Unity with UniTask(EN)
PDF
Introduction to Game Development
PDF
Windbg랑 친해지기
PDF
PPTX
Introduction to Game Engine: Concepts & Components
PDF
JavaScript guide 2020 Learn JavaScript
한컴MDS_NVIDIA Jetson Platform
jQuery for beginners
Deep Dive async/await in Unity with UniTask(EN)
Introduction to Game Development
Windbg랑 친해지기
Introduction to Game Engine: Concepts & Components
JavaScript guide 2020 Learn JavaScript

What's hot (20)

PPTX
Web development with Python
PPT
Javascript
PPTX
HTML5 & CSS3
PDF
게임사를 위한 Amazon GameLift 세션 - 이정훈, AWS 솔루션즈 아키텍트
PDF
[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기
PDF
Game design document template for serious games
PDF
Ten page document
PDF
RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析
PPTX
CSS_Day_Three (W3schools)
PDF
전형규, SilvervineUE4Lua: UE4에서 Lua 사용하기, NDC2019
PDF
Local Storage for Web Applications
PPTX
Game Design Document - Step by Step Guide
PDF
PDF
Convert Your Legacy OpenGL Code to Modern OpenGL with Qt
 
PPT
JavaScript - An Introduction
PPT
PDF
Game design doc template
PDF
Javascript Basic
ODP
Q4.11: Porting Android to new Platforms
PDF
Introduction to html 5
Web development with Python
Javascript
HTML5 & CSS3
게임사를 위한 Amazon GameLift 세션 - 이정훈, AWS 솔루션즈 아키텍트
[NDC17] Unreal.js - 자바스크립트로 쉽고 빠른 UE4 개발하기
Game design document template for serious games
Ten page document
RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析
CSS_Day_Three (W3schools)
전형규, SilvervineUE4Lua: UE4에서 Lua 사용하기, NDC2019
Local Storage for Web Applications
Game Design Document - Step by Step Guide
Convert Your Legacy OpenGL Code to Modern OpenGL with Qt
 
JavaScript - An Introduction
Game design doc template
Javascript Basic
Q4.11: Porting Android to new Platforms
Introduction to html 5
Ad

Viewers also liked (20)

PPSX
An Introduction To Game development
PDF
Experience sheet
PDF
Boston Real Estate Cash Buyer Profile 2013
PDF
Tourism for development
PPTX
Metro cash & carry
PPT
Managing Abu Dhabi's $627 Billion Sovereign Wealth Fund (ADIA), Presentation ...
PPTX
Development gap
PPT
Passive review present past
PPTX
Simple Past and Past Perfect: Passive Voice
PDF
제 5회 DGMIT R&D 컨퍼런스: JavsScript Event Bubbling & Capturing
PPT
Using video games for educational purposes
PPT
Sheets of Paper Shapes
KEY
Artificial Intelligence in Computer and Video Games
PPT
Node js presentation
PPTX
Introduction Node.js
PDF
일본온라인게임업계의코스트
PDF
Compose Async with RxJS
PPT
Ppt.online games
PDF
Modern UI Development With Node.js
PPTX
The negative and positive impacts of video games
An Introduction To Game development
Experience sheet
Boston Real Estate Cash Buyer Profile 2013
Tourism for development
Metro cash & carry
Managing Abu Dhabi's $627 Billion Sovereign Wealth Fund (ADIA), Presentation ...
Development gap
Passive review present past
Simple Past and Past Perfect: Passive Voice
제 5회 DGMIT R&D 컨퍼런스: JavsScript Event Bubbling & Capturing
Using video games for educational purposes
Sheets of Paper Shapes
Artificial Intelligence in Computer and Video Games
Node js presentation
Introduction Node.js
일본온라인게임업계의코스트
Compose Async with RxJS
Ppt.online games
Modern UI Development With Node.js
The negative and positive impacts of video games
Ad

Similar to Game Development With HTML5 (20)

PDF
Is HTML5 Ready? (workshop)
PDF
Is html5-ready-workshop-110727181512-phpapp02
PDF
The things browsers can do! SAE Alumni Convention 2014
PDF
webinale2011_Chris Mills_Brave new world of HTML5Html5
PDF
Brave new world of HTML5
PDF
Browsers with Wings
PPTX
CreateJS
PDF
A More Flash Like Web?
PPTX
HTML5 and Other Modern Browser Game Tech
PDF
JavaOne 2009 - 2d Vector Graphics in the browser with Canvas and SVG
PDF
HTML5: friend or foe (to Flash)?
PDF
HTML5 - Daha Flash bir web?
PDF
Google's HTML5 Work: what's next?
PDF
How to build a html5 websites.v1
PPTX
About Best friends - HTML, CSS and JS
PDF
HTML5 (and friends) - History, overview and current status - jsDay Verona 11....
PDF
HTML5: where flash isn't needed anymore
PDF
HTML5 after the hype - JFokus2015
PDF
HTML5, the new buzzword
PDF
HTML5 APIs - native multimedia support and beyond - University of Leeds 05.05...
Is HTML5 Ready? (workshop)
Is html5-ready-workshop-110727181512-phpapp02
The things browsers can do! SAE Alumni Convention 2014
webinale2011_Chris Mills_Brave new world of HTML5Html5
Brave new world of HTML5
Browsers with Wings
CreateJS
A More Flash Like Web?
HTML5 and Other Modern Browser Game Tech
JavaOne 2009 - 2d Vector Graphics in the browser with Canvas and SVG
HTML5: friend or foe (to Flash)?
HTML5 - Daha Flash bir web?
Google's HTML5 Work: what's next?
How to build a html5 websites.v1
About Best friends - HTML, CSS and JS
HTML5 (and friends) - History, overview and current status - jsDay Verona 11....
HTML5: where flash isn't needed anymore
HTML5 after the hype - JFokus2015
HTML5, the new buzzword
HTML5 APIs - native multimedia support and beyond - University of Leeds 05.05...

More from Gil Megidish (6)

PDF
My Adventures in Twitch Dev
PDF
Hack The Mob: Modifying Closed-source Android Apps
PPT
I Heart Stuxnet
PPT
0x4841434b45525a – H4x0r presentation for n00bs
PPT
Crash Course in Perl – Perl tutorial for C programmers
PPT
Small Teams Kick Ass
My Adventures in Twitch Dev
Hack The Mob: Modifying Closed-source Android Apps
I Heart Stuxnet
0x4841434b45525a – H4x0r presentation for n00bs
Crash Course in Perl – Perl tutorial for C programmers
Small Teams Kick Ass

Recently uploaded (20)

PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Empathic Computing: Creating Shared Understanding
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Electronic commerce courselecture one. Pdf
PDF
KodekX | Application Modernization Development
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Network Security Unit 5.pdf for BCA BBA.
PPT
Teaching material agriculture food technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
NewMind AI Weekly Chronicles - August'25 Week I
Empathic Computing: Creating Shared Understanding
Mobile App Security Testing_ A Comprehensive Guide.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Digital-Transformation-Roadmap-for-Companies.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Electronic commerce courselecture one. Pdf
KodekX | Application Modernization Development
Advanced methodologies resolving dimensionality complications for autism neur...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Spectral efficient network and resource selection model in 5G networks
Per capita expenditure prediction using model stacking based on satellite ima...
Network Security Unit 5.pdf for BCA BBA.
Teaching material agriculture food technology
Encapsulation_ Review paper, used for researhc scholars
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...

Game Development With HTML5

  • 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
  • 7. Why Bother With Javascript? Fun to develop Hacker’s spielplatz! Fast deployment Serve static files Easy to debug alert(), firebug.. Still better than the alternative! Open source and free tools Notepad, vi, emacs B.Y.O. framework jQuery? spielplatz
  • 8. But Why REALLY? Has been around for ages Won’t go away any time soon Wide support: Web browsers Mobile devices Facebook applications On a rocket near you
  • 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
  • 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.  
  • 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 <canvas id=“graphics” width=“640” height=“480”> Guru Meditation: No canvas supported! </canvas> var canvas = document.getElementById(“graphics”); var context = canvas.getContext(“2d”);
  • 22.  
  • 23. Drawing Primitives ctx.fillStyle = “#c80000&quot;; ctx.fillRect (10, 10, 55, 50); ctx.fillStyle = &quot;rgba(0, 0, 200, 0.5)&quot;; ctx.fillRect (30, 30, 55, 50); Other drawing methods: arc, bezierCurve, lineTo, quadraticCurve, rect, stroke, fillText, strokeText, beginPath/closePath and fill
  • 24. (but who needs that ?)
  • 25. Drawing Images var sprite = new Image(); sprite.src = “luigi.png”; var x = 0, y = 0; ctx.drawImage(sprite, x, y);
  • 26. Drawing Images 2 var spritemap = new Image(); spritemap.src = “sprite-map.png”; ctx.drawImage( spritemap, sx, sy, sw, sh, dx, dy, dw, dh ); 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 var block = ctx.getImageData(sx, sy, sw, sh); block = { width: width in pixels, height: height in pixels, data: array of 4*width*height bytes }; Alternatively: ctx.createImageData(w, h);
  • 29. Accessing Pixels var block = ctx.getImageData(0, 0, canvas.width/2, canvas.height); for (var y=0; y<block.height; y++) { for (var x=0; x<block.width; x++) { block.data[(y*block.width+x)*4+0] ^= 0xff; block.data[(y*block.width+x)*4+1] ^= 0xff; block.data[(y*block.width+x)*4+2] ^= 0xff; } } ctx.putImageData(block, 0, 0);
  • 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/
  • 32. Let There Be Sound! <audio id=“sfx001” src=“/mp3/boom.mp3”></audio> $(“sfx001”).play();
  • 33. Let There Be Sound! <audio id=“sfx001” src=“/mp3/boom.mp3”></audio> $(“sfx001”).play(); Other methods: $(“sfx001”).pause(); Other attributes: $(“sfx001”).currentTime = 35.0; $(“sfx001”).volume = 0.5; $(“sfx001”).duration (read only)
  • 34. Putting It All Together
  • 35. Typical Game Loop function gameTick() { processKeyboard(); moveEnemies(); drawGraphics(); updateAudio(); } var fps = 60; setInterval(gameTick, 1000 / fps);
  • 36. The Future is Upon Us!
  • 38. What’s Coming Up Next WebGL OpenGL interface for Javascript As of May, 2010: good luck finding a stable browser! WebSocket UDP and nonblocking transport layer Not there yet! (KAAZING?) WebStorage Save games?
  • 39. Code Like It’s 2020! ftw! ‘ s Blackberry coming June 1 st !
  • 40. Q&A
  • 41. Q&A Yes! You can use <canvas> in Internet Explorer 6? <!--[if IE]> <script type=&quot;text/javascript“ src=&quot;/js/excanvas.js&quot;> </script> <![endif]--> PS. Remember to upgrade your mother’s IE!
  • 42. Links! Chrome Experiments: Not Your Momma’s JS http://www.chromeexperiments.com Appcelerator’s Titanium www.appcelerator.com Box 2D: real time physics for JS games http://box2d-js.sourceforge.net/index2.html Mozilla’s Canvas tutorial https:// developer.mozilla.org/en/Canvas_tutorial
  • 43.  
  • 44. GO MAKE GAMES! http://www.megidish.net