SlideShare a Scribd company logo
Building 2D HTML5 Games:
Myths and Reality
Sergey Batishchev
https://twitter.com/sergebat
Some of our HTML5 Games
<TL;DR>
© dracoimagem-com.deviantart.com, used with permission
Why are we doing it?
Playing in Mobile Browser
Reach New Platforms
Bad Reason:
“Write once run everywhere”
debug
“Plugin-free”
What exactly is HTML5? *
* for 2D games
• <canvas>
• Web Audio API
• Touch API
• Local Storage API
• WebGL
But HTML and JS are
sloooow?!
Canvas Performance
iPhone 4s + iOS7.1 = 47 FPS
SGS3 + Android 4.3 Chrome = 38 FPS
500 sprites per frame
Canvas IS GPU
Accelerated!
•iOS 5.0 beta +
• https://developer.apple.com/safari/features/
•Chrome for Android (4.0+)
• https://developer.chrome.com/multidevice/android/overview?csw=1
Stock Android Browser – ?
Android Stock Browser
500 sprites + SGS3 + Android 4.3 Stock
= 8 FPS 
80 sprites + SGS3 + Android 4.3 Stock
= 40 FPS
Some pitfalls are real…
Implicit Texture Loading
void drawImage( in nsIDOMElement image,
in float sx,
in float sy,
in float sw,
in float sh,
in float dx,
in float dy,
in float dw,
in float dh );
GPU vs In-Memory
Canvases
<=256x256
(In chrome)
256x256+
(In chrome)
Small: 256x256
Avg: 257x257
http://jsperf.com/mixedcanvases
Pure JS Performance
From “The Computer Language Benchmarks Game”
http://benchmarksgame.alioth.debian.org/
JIT Friendly JS
https://developers.google.com/events/io/2012/sessions/gooio2012/224/
Сергей Батищев: 2D игры на HTML5: мифы и реальность разработки
Preloader
• assets
• img
• spritsheet.png
• background.png
• menubackground.png
• …
• sound
• tap.m4a
• tap.ogg
• …
• js
• game.min.js
• index.html
Sound
• Various formats (m4a, ogg)
• Web Audio, fallback to HTML Audio Tag
• Browser quirks
Render and UI
•Organize spritesheets
•Stage, display lists
•Touch, hit test
But JS engines are
even slower?!
500 sprites
iPhone 4s + iOS7.1 =
47 FPS
SGS3 + Android 4.3 Chrome =
38 FPS
SGS3 + Android 4.3 Stock =
8 FPS
iPhone 4s + iOS7.1 =
30 FPS
SGS3 + Android 4.3 Chrome =
24 FPS
SGS3 + Android 4.3 Stock =
7 FPS
Which engine to choose?
Thoughts on selection
•Canvas / WebGL / Both?
•Big guys behind it?
•JS/HTML is a priority for them?
•Hackable?
•Can build SWF/APK/IPA?
But supporting all
browsers/devices is
painful?!
Should work well on:
• Browsers
• iOS Safari 6.0 +
• Android Browser 4.0+
• Android Chrome 4.0+
• Popular devices (1-2 year old)
• iPhone 4S, iPad 2 and newer
• Galaxy S3, Galaxy Tab, etc
Playable (more or less)
• iPhone 4, iPad 1
• Galaxy S2/S1/Y
Desktop is often
secondary objective
•Two last Chrome versions
•Two last Mozilla versions
•IE 9.0 +
Keep it Simple
•Pure canvas, no DOM
• Libs like Zynga Scroller can help
•Just 1 canvas
•Test on at least one device
Various screen sizes
are painful!
Full Screen
•Proper
• Full screen API (requestFullscreen)
•Hack
• scrollTo
• Zynga Scroller to handle the tricks
• minimal-ui
• iPhone on iOS 7.1+ only
Lock Orientation APO is
not widely available (yet)
Dangerous Gestures
Swipe entire screen left/right
Swipe from the top
Tap the top
Careful with Horizontal
Orientation
Background
My choice for now
640x960
Vertically
oriented
game area
640x712
Please rotate your phone
Sound Support
iOS 6.0+
• WebAudio is well supported
• Supported format: M4A
• Play sound in user interaction
to unmute
Android Chrome
• WebAudio is well supported
• Supported format: OGG
Android Stock Browser
• Only HTML audio tag
• Supported format: OGG
• Huge delays/sync issues
print(“Hello World”)
fillText
iPhone 4s + iOS7.1 = 60 FPS
SGS3 + Android 4.3 Chrome = 43 FPS
SGS3 + Android 4.3 Stock = 34 FPS
200 text labels per frame
Multiline Text
FPS is ½ of
plain fillText
(in CreateJS)
fillText is not
pixel-accurate
Chrome (and friends) Firefox and friends
Touch vs Mouse Events
Some devices have
both!
preventDefault();
Touch events
Mouse events
Customers and their API
• Easy and common:
• Add logo + splash (PNG/JPG)
• Add animated preloader (HTML+JS)
• Submit scores
• Submit start/gameover/levelend/etc
• Work in iframe, custom resize
• Harder and rare:
• Work in “their” API canvas
• Custom path to load resources (CDN)
Wrapping Apps
Dreaded WebView
• iOS:
• No JIT in WebView
• Canvas is likely not hardware accelerated
• Hint: test on Chrome for iOS
• Android:
• Based on standard Android Browser
before 4.4
• Canvas is NOT hardware accelerated
How do we make
apps from HTML5 then?
+ High performance canvas embedded
+ Works across iOS/Android/WinPhone
- Custom extensions are coming
- Mandatory splash screen
+ “Real Chromium” embedded
+ Open source, backed by Intel XDK
- ~20MB min APK, only Android 4+
+ Mature, well supported
+ Open source, optional cloud build,
backed by Adobe
- WebView
- External “FastCanvas” is not easy to support
Questions?
Sergey Batishchev
twitter.com/sergebat
html5devgamm2014.bitbucket.org

More Related Content

KEY
Skip the IDE with PhoneGap Build
PDF
W3C HTML5 KIG-The near future of the web platform
PPTX
Developing Apps for the BlackBerry PlayBook
PPTX
WebVR, not just Holograms in the web but powerful platform
PPTX
Wrapping with PhoneGap
PDF
Achieving Scale with HoloLens and BIM: Designing for interactions with large ...
PDF
PhoneGap mobile development
PDF
Adventures in cross platform ConnectJS / TiConnect 2014
Skip the IDE with PhoneGap Build
W3C HTML5 KIG-The near future of the web platform
Developing Apps for the BlackBerry PlayBook
WebVR, not just Holograms in the web but powerful platform
Wrapping with PhoneGap
Achieving Scale with HoloLens and BIM: Designing for interactions with large ...
PhoneGap mobile development
Adventures in cross platform ConnectJS / TiConnect 2014

What's hot (11)

PDF
fpadvanced
PDF
Successful Web Typography - The Developer's Ampersandwich
PPTX
Java script programming language
PDF
Marmalade: bittersweet experience
PPTX
Phaser presentation
PPTX
Introduction to Phaser.js
PPTX
Marmalade bittersweet experience
PPTX
Html5 player for Course Online System
KEY
jQueryUI and HTML5 Video Play Nice
PDF
Absolutist: Porting to major platforms within a minute
PDF
Joomlatools Extension Logos - A separate logo for each extension
fpadvanced
Successful Web Typography - The Developer's Ampersandwich
Java script programming language
Marmalade: bittersweet experience
Phaser presentation
Introduction to Phaser.js
Marmalade bittersweet experience
Html5 player for Course Online System
jQueryUI and HTML5 Video Play Nice
Absolutist: Porting to major platforms within a minute
Joomlatools Extension Logos - A separate logo for each extension
Ad

Similar to Сергей Батищев: 2D игры на HTML5: мифы и реальность разработки (20)

KEY
Phonegap for Engineers
PPTX
Making HTML5 Games with Phaser
KEY
HTML5 is the Future of Mobile, PhoneGap Takes You There Today
PPT
Multi-platform Mobile apps with Phonegap
PDF
iOS and Android Development with Unity3D
PDF
HTML5 Games Status and issues
PDF
Cordova and PhoneGap Insights
PPTX
From Web to Mobile with Stage 3D
PPTX
Developing Windows Phone 8 apps using PhoneGap
PPTX
Cross-Platform Development
PDF
Web DU Mobile Meow
PDF
Adobe: Adobe Gaming NOW!
PDF
Adobe gaming flash gamm michael
PDF
JS Days Mobile Meow
PPTX
OGDC2013_ Cross platform game development with html5_ Mr Hoang Dinh Quang
PPTX
Ogdc 2013 cross platform game development with html5
PDF
Extreme Web Performance for Mobile Devices - Velocity Barcelona 2014
PPTX
2011 code camp
PDF
Mobile Meow at Mobilism
KEY
Future of Mobile
Phonegap for Engineers
Making HTML5 Games with Phaser
HTML5 is the Future of Mobile, PhoneGap Takes You There Today
Multi-platform Mobile apps with Phonegap
iOS and Android Development with Unity3D
HTML5 Games Status and issues
Cordova and PhoneGap Insights
From Web to Mobile with Stage 3D
Developing Windows Phone 8 apps using PhoneGap
Cross-Platform Development
Web DU Mobile Meow
Adobe: Adobe Gaming NOW!
Adobe gaming flash gamm michael
JS Days Mobile Meow
OGDC2013_ Cross platform game development with html5_ Mr Hoang Dinh Quang
Ogdc 2013 cross platform game development with html5
Extreme Web Performance for Mobile Devices - Velocity Barcelona 2014
2011 code camp
Mobile Meow at Mobilism
Future of Mobile
Ad

More from DevGAMM Conference (20)

PPTX
The art of small steps, or how to make sound for games in conditions of war /...
PPTX
Breaking up with FMOD - Why we ended things and embraced Metasounds / Daniel ...
PPTX
How Audio Objects Improve Spatial Accuracy / Mads Maretty Sønderup (Audiokine...
PPTX
Why indie developers should consider hyper-casual right now / Igor Gurenyov (...
PPTX
AI / ML for Indies / Tyler Coleman (Retora Games)
PDF
Agility is the Key: Power Up Your GameDev Project Management with Agile Pract...
PPTX
New PR Tech and AI Tools for 2023: A Game Changer for Outreach / Kirill Perev...
PDF
Playable Ads - Revolutionizing mobile games advertising / Jakub Kukuryk (Popc...
PDF
Creative Collaboration: Managing an Art Team / Nastassia Radzivonava (Glera G...
PDF
From Local to Global: Unleashing the Power of Payments / Jan Kuhlmannn (Xsolla)
PDF
Strategies and case studies to grow LTV in 2023 / Julia Iljuk (Balancy)
PDF
Why is ASO not working in 2023 and how to change it? / Olena Vedmedenko (Keya...
PDF
How to increase wishlists & game sales from China? Growth marketing tactics &...
PDF
Turkish Gaming Industry and HR Insights / Mustafa Mert EFE (Zindhu)
PDF
Building an Awesome Creative Team from Scratch, Capable of Scaling Up / Sasha...
PPTX
Seven Reasons Why Your LiveOps Is Not Performing / Alexander Devyaterikov (Be...
PDF
The Power of Game and Music Collaborations: Reaching and Engaging the Masses ...
PPTX
Branded Content: How to overcome players' immunity to advertising / Alex Brod...
PPTX
Resurrecting Chasm: The Rift - A Source-less Remastering Journey / Gennadii P...
PPTX
How NOT to do showcase events: Behind the scenes of Midnight Show / Andrew Ko...
The art of small steps, or how to make sound for games in conditions of war /...
Breaking up with FMOD - Why we ended things and embraced Metasounds / Daniel ...
How Audio Objects Improve Spatial Accuracy / Mads Maretty Sønderup (Audiokine...
Why indie developers should consider hyper-casual right now / Igor Gurenyov (...
AI / ML for Indies / Tyler Coleman (Retora Games)
Agility is the Key: Power Up Your GameDev Project Management with Agile Pract...
New PR Tech and AI Tools for 2023: A Game Changer for Outreach / Kirill Perev...
Playable Ads - Revolutionizing mobile games advertising / Jakub Kukuryk (Popc...
Creative Collaboration: Managing an Art Team / Nastassia Radzivonava (Glera G...
From Local to Global: Unleashing the Power of Payments / Jan Kuhlmannn (Xsolla)
Strategies and case studies to grow LTV in 2023 / Julia Iljuk (Balancy)
Why is ASO not working in 2023 and how to change it? / Olena Vedmedenko (Keya...
How to increase wishlists & game sales from China? Growth marketing tactics &...
Turkish Gaming Industry and HR Insights / Mustafa Mert EFE (Zindhu)
Building an Awesome Creative Team from Scratch, Capable of Scaling Up / Sasha...
Seven Reasons Why Your LiveOps Is Not Performing / Alexander Devyaterikov (Be...
The Power of Game and Music Collaborations: Reaching and Engaging the Masses ...
Branded Content: How to overcome players' immunity to advertising / Alex Brod...
Resurrecting Chasm: The Rift - A Source-less Remastering Journey / Gennadii P...
How NOT to do showcase events: Behind the scenes of Midnight Show / Andrew Ko...

Recently uploaded (20)

DOCX
"Project Management: Ultimate Guide to Tools, Techniques, and Strategies (2025)"
PPT
First Aid Training Presentation Slides.ppt
PPTX
FINAL TEST 3C_OCTAVIA RAMADHANI SANTOSO-1.pptx
PPTX
Sustainable Forest Management ..SFM.pptx
PPTX
PHIL.-ASTRONOMY-AND-NAVIGATION of ..pptx
PPT
The Effect of Human Resource Management Practice on Organizational Performanc...
PPTX
Project and change Managment: short video sequences for IBA
PPTX
AcademyNaturalLanguageProcessing-EN-ILT-M02-Introduction.pptx
PPTX
nose tajweed for the arabic alphabets for the responsive
PDF
Presentation1 [Autosaved].pdf diagnosiss
PDF
Instagram's Product Secrets Unveiled with this PPT
PDF
Swiggy’s Playbook: UX, Logistics & Monetization
PPTX
lesson6-211001025531lesson plan ppt.pptx
PPTX
Presentation for DGJV QMS (PQP)_12.03.2025.pptx
PPTX
worship songs, in any order, compilation
PDF
Yusen Logistics Group Sustainability Report 2024.pdf
PPTX
water for all cao bang - a charity project
PPTX
Tour Presentation Educational Activity.pptx
PPTX
Impressionism_PostImpressionism_Presentation.pptx
PPTX
An Unlikely Response 08 10 2025.pptx
"Project Management: Ultimate Guide to Tools, Techniques, and Strategies (2025)"
First Aid Training Presentation Slides.ppt
FINAL TEST 3C_OCTAVIA RAMADHANI SANTOSO-1.pptx
Sustainable Forest Management ..SFM.pptx
PHIL.-ASTRONOMY-AND-NAVIGATION of ..pptx
The Effect of Human Resource Management Practice on Organizational Performanc...
Project and change Managment: short video sequences for IBA
AcademyNaturalLanguageProcessing-EN-ILT-M02-Introduction.pptx
nose tajweed for the arabic alphabets for the responsive
Presentation1 [Autosaved].pdf diagnosiss
Instagram's Product Secrets Unveiled with this PPT
Swiggy’s Playbook: UX, Logistics & Monetization
lesson6-211001025531lesson plan ppt.pptx
Presentation for DGJV QMS (PQP)_12.03.2025.pptx
worship songs, in any order, compilation
Yusen Logistics Group Sustainability Report 2024.pdf
water for all cao bang - a charity project
Tour Presentation Educational Activity.pptx
Impressionism_PostImpressionism_Presentation.pptx
An Unlikely Response 08 10 2025.pptx

Сергей Батищев: 2D игры на HTML5: мифы и реальность разработки