SlideShare a Scribd company logo
Modeling Patterns for JavaScript Browser-Based GamesJarodLong           Ray ToalLoyola Marymount UniversityLos Angeles, CA USA2011-05-16
Topics	Overview of ContributionsChallenges for Browser-Based GamesWhat’s new with JavaScriptPatterns vs. FrameworksContributions in DetailJavaScript and HTML5 Game EnginesSummary
ContributionsDevelopment of JavaScript design patterns specifically for modules and typesNote: patterns, not frameworksPatterns are independent of game engineApplication of these patterns in a 2-D, physics-based, HTML5 gameSurvey of JavaScript game engines
Browser-Based Game IssuesRich domain models OOP was motivated by graphical applicationsGraphics and physics enginesCan mix Canvas and the DOM don’t forget CSS! (esp. CSS3)Full source code visibilityAjaxHigh score lists difficult to implement
JavaScriptThe most popular language for programming the client-side web (competes with Flash and Java)Created in 1996 but only “understood” in mid 2000sRecent AdvancesECMAScript 5V8 and other modern engines (>100x faster)Server-side (e.g., node.js)(BIG FUTURE IN THIS)
JavaScript OverviewArray and object literalsvarx = [3, “true”, 2.2];var point = {lat: 27.95, lon: -140.4};A functional programming language -- closer to Scheme than CmyArray.map(function (x) {return x * x;});data.map(square).filter(isOdd).reduce(plus);Prototypes, not classesvarmyCircle = Object.create(yourCircle);myCircle.color = “rgb(23,100, 122)”;
Software ModelingGames are naturally event-driven and feature an object-oriented architectureModules and TypesCommon types: vector, sprite, fortress, level, weapon, enemy, projectile, …Common modules (singletons): math, world, camera, game, util, ui, input, contact, … How can these be represented in JavaScript?
JavaScript Prototypesvarc = {x: 0, y: 0,     radius: 1,    color: black};var c1 = Object.create(c);c1.x = 3; c1.color = "green";var c2 = Object.create(c);c1.x = 4; c1.radius = 15;var c3 = Object.create(c);assert(c2.color === "black");The prototype is NOT a "class" object
Shared Behavior in Prototypesvarc = {x: 0, y: 0, radius: 1, color: black,    area: function () {return this.radius * Math.PI * Math.PI;},    . . .};Because we don't want separate function copies in each object
Inheritance  Inheritance and overriding easy with prototypes
  But how to do "super"?  Do we care?Implementation ApproachesUse JavaScript's new (pseudo-classical?)Adopt a framework that does classes ("class", "extend", "inherit", "super", …)Dean Edwards' BaseMooToolsMany others . . .Embrace prototypes and use patterns"Frameworks (sort of) change the language"
A Module Pattern<package>.M = (function () {var privatePropertyOrMethod1 = …;    …var M = {};    M.publicProperty1 = …;    M.publicMethod1 = function (…) {…};    …    return M;}());Already familiar to JavaScript professionals(We just prefer avoiding object literals)
Type Pattern<package>.T = (function () {var T = {};    ...T.create = function (…) {vart = Object.create(this);        ...        return t;    }    return T;}());Instantiate with:  varx = <package>.T.create(…);The "type" object and the prototype are one!  Differs from operator new, which equates the type with the constructor (prototype separate)Shared properties and methods go hereAssign theown propertieshere
Root Types<package>.GameObject = (function () {varGameObject = {};GameObject.GameObject = GameObject;GameObject.create = function (id) {varg = Object.create(this);g.id = id;        return g;    }GameObject.update = function () {alert("Updating game object " + this.id);    }    return GameObject;}());Self reference will allow multiple levels of "super"Of course we are going to override this on the next slide
Subtypes<package>.Projectile = (function () {var Projectile = Object.create(<package>.GameObject);Projectile.Projectile = Projectile;Projectile.create = function (id, name) {varp = <package>.GameObject.create.call(this, id);p.name = name;        return p;    }Projectile.update = function () {  // override!this.GameObject.update.call(this);alert("Updating projectile " + this.name);    }       return Projectile;}());Note use of "this" instead of the package name – it shows we are using an ancestor type
Subtypes, Slightly Cleaner<package>.Projectile = (function (supertype) {var Projectile = Object.create(supertype);Projectile.Projectile = Projectile;Projectile.create = function (id, name) {varp = supertype.create.call(this, id);p.name = name;        return p;    }Projectile.update = function () {  // override!supertype.update.call(this);alert("Updating projectile " + this.name);    }       return Projectile;}(package.GameObject));Or mention an ancestor type directly
How it all LooksPrivate data from closures not shown
Applicationshttp://manicmonkeymadness.googlecode.com
Why is this Useful?No extra scripts to includeNo framework to learn No need to say "new Base" and ".extend""Super" functionality is still available if neededProgrammer can apply the pattern selectivelyIt's real JavaScript Closures and Function.call are hardcoreMaintains prototypal feel, even though class-likeType.create()
JavaScript Game EnginesThe Render EngineImpactAves (Zynga Germany)EffectIsogenicgameQueryRocket Engine (acquired by Disney)See engine lists and comparisons athttps://github.com/bebraw/jswiki/wiki/Game-Enginesandhttp://www.cssgalleries.com/2011/02/the-big-list-of-javascript-game-engines/
SummaryGames benefit from an object-oriented, event-driven architectureMany approaches exist for modeling an OO software architecture in JavaScriptWe presented framework-free, engine independent modeling patternsPatterns were applied in a real HTML5, no-Flash application

More Related Content

What's hot (17)

Java OOP Concept
Java OOP ConceptJava OOP Concept
Java OOP Concept
NikitaGour5
 
David container security-with_falco
David container security-with_falcoDavid container security-with_falco
David container security-with_falco
Lorenzo David
 
Slideshare - linux crypto
Slideshare - linux cryptoSlideshare - linux crypto
Slideshare - linux crypto
Jin Wu
 
Jvm分享20101228
Jvm分享20101228Jvm分享20101228
Jvm分享20101228
lunfu zhong
 
Note - (EDK2) HII Compile
Note - (EDK2) HII CompileNote - (EDK2) HII Compile
Note - (EDK2) HII Compile
boyw165
 
Core Java
Core JavaCore Java
Core Java
Prakash Dimmita
 
Generic programming and concepts that should be in C++
Generic programming and concepts that should be in C++Generic programming and concepts that should be in C++
Generic programming and concepts that should be in C++
Anton Kolotaev
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device drivers
Alexandre Moreno
 
Embedded Operating System - Linux
Embedded Operating System - LinuxEmbedded Operating System - Linux
Embedded Operating System - Linux
Emertxe Information Technologies Pvt Ltd
 
Asynchronous Python A Gentle Introduction
Asynchronous Python A Gentle IntroductionAsynchronous Python A Gentle Introduction
Asynchronous Python A Gentle Introduction
PyData
 
Java Methods
Java MethodsJava Methods
Java Methods
OXUS 20
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modules
dibyajyotig
 
Object oriented programming With C#
Object oriented programming With C#Object oriented programming With C#
Object oriented programming With C#
Youssef Mohammed Abohaty
 
Red Hat OpenStack 17 저자직강+스터디그룹_1주차
Red Hat OpenStack 17 저자직강+스터디그룹_1주차Red Hat OpenStack 17 저자직강+스터디그룹_1주차
Red Hat OpenStack 17 저자직강+스터디그룹_1주차
Nalee Jang
 
Javaプログラマのための頑張らないGo入門
Javaプログラマのための頑張らないGo入門Javaプログラマのための頑張らないGo入門
Javaプログラマのための頑張らないGo入門
yy yank
 
SignaturesAreDead Long Live RESILIENT Signatures
SignaturesAreDead Long Live RESILIENT SignaturesSignaturesAreDead Long Live RESILIENT Signatures
SignaturesAreDead Long Live RESILIENT Signatures
Daniel Bohannon
 
Drone CI/CD Platform
Drone CI/CD PlatformDrone CI/CD Platform
Drone CI/CD Platform
Bo-Yi Wu
 
Java OOP Concept
Java OOP ConceptJava OOP Concept
Java OOP Concept
NikitaGour5
 
David container security-with_falco
David container security-with_falcoDavid container security-with_falco
David container security-with_falco
Lorenzo David
 
Slideshare - linux crypto
Slideshare - linux cryptoSlideshare - linux crypto
Slideshare - linux crypto
Jin Wu
 
Jvm分享20101228
Jvm分享20101228Jvm分享20101228
Jvm分享20101228
lunfu zhong
 
Note - (EDK2) HII Compile
Note - (EDK2) HII CompileNote - (EDK2) HII Compile
Note - (EDK2) HII Compile
boyw165
 
Generic programming and concepts that should be in C++
Generic programming and concepts that should be in C++Generic programming and concepts that should be in C++
Generic programming and concepts that should be in C++
Anton Kolotaev
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device drivers
Alexandre Moreno
 
Asynchronous Python A Gentle Introduction
Asynchronous Python A Gentle IntroductionAsynchronous Python A Gentle Introduction
Asynchronous Python A Gentle Introduction
PyData
 
Java Methods
Java MethodsJava Methods
Java Methods
OXUS 20
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modules
dibyajyotig
 
Red Hat OpenStack 17 저자직강+스터디그룹_1주차
Red Hat OpenStack 17 저자직강+스터디그룹_1주차Red Hat OpenStack 17 저자직강+스터디그룹_1주차
Red Hat OpenStack 17 저자직강+스터디그룹_1주차
Nalee Jang
 
Javaプログラマのための頑張らないGo入門
Javaプログラマのための頑張らないGo入門Javaプログラマのための頑張らないGo入門
Javaプログラマのための頑張らないGo入門
yy yank
 
SignaturesAreDead Long Live RESILIENT Signatures
SignaturesAreDead Long Live RESILIENT SignaturesSignaturesAreDead Long Live RESILIENT Signatures
SignaturesAreDead Long Live RESILIENT Signatures
Daniel Bohannon
 
Drone CI/CD Platform
Drone CI/CD PlatformDrone CI/CD Platform
Drone CI/CD Platform
Bo-Yi Wu
 

Similar to Modeling Patterns for JavaScript Browser-Based Games (20)

Developing High Performance Websites and Modern Apps with JavaScript and HTML5
Developing High Performance Websites and Modern Apps with JavaScript and HTML5Developing High Performance Websites and Modern Apps with JavaScript and HTML5
Developing High Performance Websites and Modern Apps with JavaScript and HTML5
Doris Chen
 
Introduction to JavaScript design patterns
Introduction to JavaScript design patternsIntroduction to JavaScript design patterns
Introduction to JavaScript design patterns
Jeremy Duvall
 
Why TypeScript?
Why TypeScript?Why TypeScript?
Why TypeScript?
FITC
 
Tamarin And Ecmascript 4
Tamarin And Ecmascript 4Tamarin And Ecmascript 4
Tamarin And Ecmascript 4
elliando dias
 
Xopus Application Framework
Xopus Application FrameworkXopus Application Framework
Xopus Application Framework
Jady Yang
 
Advanced JavaScript
Advanced JavaScript Advanced JavaScript
Advanced JavaScript
Zsolt Mészárovics
 
Dojo for programmers (TXJS 2010)
Dojo for programmers (TXJS 2010)Dojo for programmers (TXJS 2010)
Dojo for programmers (TXJS 2010)
Eugene Lazutkin
 
Typescript - A developer friendly javascript
Typescript - A developer friendly javascriptTypescript - A developer friendly javascript
Typescript - A developer friendly javascript
pradiphudekar
 
V8
V8V8
V8
Burcu Dogan
 
The Future of JavaScript (Ajax Exp '07)
The Future of JavaScript (Ajax Exp '07)The Future of JavaScript (Ajax Exp '07)
The Future of JavaScript (Ajax Exp '07)
jeresig
 
OSCON Presentation: Developing High Performance Websites and Modern Apps with...
OSCON Presentation: Developing High Performance Websites and Modern Apps with...OSCON Presentation: Developing High Performance Websites and Modern Apps with...
OSCON Presentation: Developing High Performance Websites and Modern Apps with...
Doris Chen
 
mloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game developmentmloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game development
David Galeano
 
JavaScript - Introduction
JavaScript - IntroductionJavaScript - Introduction
JavaScript - Introduction
Tomasz Masternak
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by Howard
LearningTech
 
Howard type script
Howard   type scriptHoward   type script
Howard type script
LearningTech
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
André Pitombeira
 
JSLounge - TypeScript 소개
JSLounge - TypeScript 소개JSLounge - TypeScript 소개
JSLounge - TypeScript 소개
Reagan Hwang
 
HTML5 - Chances and Pitfalls (Bytro Labs GmbH)
HTML5 - Chances and Pitfalls (Bytro Labs GmbH)HTML5 - Chances and Pitfalls (Bytro Labs GmbH)
HTML5 - Chances and Pitfalls (Bytro Labs GmbH)
Felix Faber
 
P Training Presentation
P Training PresentationP Training Presentation
P Training Presentation
Gaurav Tyagi
 
Design pattern
Design patternDesign pattern
Design pattern
Shreyance Jain
 
Developing High Performance Websites and Modern Apps with JavaScript and HTML5
Developing High Performance Websites and Modern Apps with JavaScript and HTML5Developing High Performance Websites and Modern Apps with JavaScript and HTML5
Developing High Performance Websites and Modern Apps with JavaScript and HTML5
Doris Chen
 
Introduction to JavaScript design patterns
Introduction to JavaScript design patternsIntroduction to JavaScript design patterns
Introduction to JavaScript design patterns
Jeremy Duvall
 
Why TypeScript?
Why TypeScript?Why TypeScript?
Why TypeScript?
FITC
 
Tamarin And Ecmascript 4
Tamarin And Ecmascript 4Tamarin And Ecmascript 4
Tamarin And Ecmascript 4
elliando dias
 
Xopus Application Framework
Xopus Application FrameworkXopus Application Framework
Xopus Application Framework
Jady Yang
 
Dojo for programmers (TXJS 2010)
Dojo for programmers (TXJS 2010)Dojo for programmers (TXJS 2010)
Dojo for programmers (TXJS 2010)
Eugene Lazutkin
 
Typescript - A developer friendly javascript
Typescript - A developer friendly javascriptTypescript - A developer friendly javascript
Typescript - A developer friendly javascript
pradiphudekar
 
The Future of JavaScript (Ajax Exp '07)
The Future of JavaScript (Ajax Exp '07)The Future of JavaScript (Ajax Exp '07)
The Future of JavaScript (Ajax Exp '07)
jeresig
 
OSCON Presentation: Developing High Performance Websites and Modern Apps with...
OSCON Presentation: Developing High Performance Websites and Modern Apps with...OSCON Presentation: Developing High Performance Websites and Modern Apps with...
OSCON Presentation: Developing High Performance Websites and Modern Apps with...
Doris Chen
 
mloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game developmentmloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game development
David Galeano
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by Howard
LearningTech
 
Howard type script
Howard   type scriptHoward   type script
Howard type script
LearningTech
 
JSLounge - TypeScript 소개
JSLounge - TypeScript 소개JSLounge - TypeScript 소개
JSLounge - TypeScript 소개
Reagan Hwang
 
HTML5 - Chances and Pitfalls (Bytro Labs GmbH)
HTML5 - Chances and Pitfalls (Bytro Labs GmbH)HTML5 - Chances and Pitfalls (Bytro Labs GmbH)
HTML5 - Chances and Pitfalls (Bytro Labs GmbH)
Felix Faber
 
P Training Presentation
P Training PresentationP Training Presentation
P Training Presentation
Gaurav Tyagi
 
Ad

More from Ray Toal (7)

Git workshop
Git workshopGit workshop
Git workshop
Ray Toal
 
Learning and Modern Programming Languages
Learning and Modern Programming LanguagesLearning and Modern Programming Languages
Learning and Modern Programming Languages
Ray Toal
 
Java best practices
Java best practicesJava best practices
Java best practices
Ray Toal
 
unittest in 5 minutes
unittest in 5 minutesunittest in 5 minutes
unittest in 5 minutes
Ray Toal
 
Convention-Based Syntactic Descriptions
Convention-Based Syntactic DescriptionsConvention-Based Syntactic Descriptions
Convention-Based Syntactic Descriptions
Ray Toal
 
An Annotation Framework for Statically-Typed Syntax Trees
An Annotation Framework for Statically-Typed Syntax TreesAn Annotation Framework for Statically-Typed Syntax Trees
An Annotation Framework for Statically-Typed Syntax Trees
Ray Toal
 
Economics of Open Source Software
Economics of Open Source SoftwareEconomics of Open Source Software
Economics of Open Source Software
Ray Toal
 
Git workshop
Git workshopGit workshop
Git workshop
Ray Toal
 
Learning and Modern Programming Languages
Learning and Modern Programming LanguagesLearning and Modern Programming Languages
Learning and Modern Programming Languages
Ray Toal
 
Java best practices
Java best practicesJava best practices
Java best practices
Ray Toal
 
unittest in 5 minutes
unittest in 5 minutesunittest in 5 minutes
unittest in 5 minutes
Ray Toal
 
Convention-Based Syntactic Descriptions
Convention-Based Syntactic DescriptionsConvention-Based Syntactic Descriptions
Convention-Based Syntactic Descriptions
Ray Toal
 
An Annotation Framework for Statically-Typed Syntax Trees
An Annotation Framework for Statically-Typed Syntax TreesAn Annotation Framework for Statically-Typed Syntax Trees
An Annotation Framework for Statically-Typed Syntax Trees
Ray Toal
 
Economics of Open Source Software
Economics of Open Source SoftwareEconomics of Open Source Software
Economics of Open Source Software
Ray Toal
 
Ad

Recently uploaded (20)

PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free DownloadViral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Ben Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding WorldBen Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding World
AWS Chicago
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdfEdge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Secure Access with Azure Active Directory
Secure Access with Azure Active DirectorySecure Access with Azure Active Directory
Secure Access with Azure Active Directory
VICTOR MAESTRE RAMIREZ
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too LateKubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free DownloadViral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Ben Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding WorldBen Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding World
AWS Chicago
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdfEdge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Secure Access with Azure Active Directory
Secure Access with Azure Active DirectorySecure Access with Azure Active Directory
Secure Access with Azure Active Directory
VICTOR MAESTRE RAMIREZ
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and ImplementationAI Agents in Logistics and Supply Chain Applications Benefits and Implementation
AI Agents in Logistics and Supply Chain Applications Benefits and Implementation
Christine Shepherd
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too LateKubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 

Modeling Patterns for JavaScript Browser-Based Games

  • 1. Modeling Patterns for JavaScript Browser-Based GamesJarodLong Ray ToalLoyola Marymount UniversityLos Angeles, CA USA2011-05-16
  • 2. Topics Overview of ContributionsChallenges for Browser-Based GamesWhat’s new with JavaScriptPatterns vs. FrameworksContributions in DetailJavaScript and HTML5 Game EnginesSummary
  • 3. ContributionsDevelopment of JavaScript design patterns specifically for modules and typesNote: patterns, not frameworksPatterns are independent of game engineApplication of these patterns in a 2-D, physics-based, HTML5 gameSurvey of JavaScript game engines
  • 4. Browser-Based Game IssuesRich domain models OOP was motivated by graphical applicationsGraphics and physics enginesCan mix Canvas and the DOM don’t forget CSS! (esp. CSS3)Full source code visibilityAjaxHigh score lists difficult to implement
  • 5. JavaScriptThe most popular language for programming the client-side web (competes with Flash and Java)Created in 1996 but only “understood” in mid 2000sRecent AdvancesECMAScript 5V8 and other modern engines (>100x faster)Server-side (e.g., node.js)(BIG FUTURE IN THIS)
  • 6. JavaScript OverviewArray and object literalsvarx = [3, “true”, 2.2];var point = {lat: 27.95, lon: -140.4};A functional programming language -- closer to Scheme than CmyArray.map(function (x) {return x * x;});data.map(square).filter(isOdd).reduce(plus);Prototypes, not classesvarmyCircle = Object.create(yourCircle);myCircle.color = “rgb(23,100, 122)”;
  • 7. Software ModelingGames are naturally event-driven and feature an object-oriented architectureModules and TypesCommon types: vector, sprite, fortress, level, weapon, enemy, projectile, …Common modules (singletons): math, world, camera, game, util, ui, input, contact, … How can these be represented in JavaScript?
  • 8. JavaScript Prototypesvarc = {x: 0, y: 0, radius: 1, color: black};var c1 = Object.create(c);c1.x = 3; c1.color = "green";var c2 = Object.create(c);c1.x = 4; c1.radius = 15;var c3 = Object.create(c);assert(c2.color === "black");The prototype is NOT a "class" object
  • 9. Shared Behavior in Prototypesvarc = {x: 0, y: 0, radius: 1, color: black, area: function () {return this.radius * Math.PI * Math.PI;}, . . .};Because we don't want separate function copies in each object
  • 10. Inheritance Inheritance and overriding easy with prototypes
  • 11. But how to do "super"? Do we care?Implementation ApproachesUse JavaScript's new (pseudo-classical?)Adopt a framework that does classes ("class", "extend", "inherit", "super", …)Dean Edwards' BaseMooToolsMany others . . .Embrace prototypes and use patterns"Frameworks (sort of) change the language"
  • 12. A Module Pattern<package>.M = (function () {var privatePropertyOrMethod1 = …; …var M = {}; M.publicProperty1 = …; M.publicMethod1 = function (…) {…}; … return M;}());Already familiar to JavaScript professionals(We just prefer avoiding object literals)
  • 13. Type Pattern<package>.T = (function () {var T = {}; ...T.create = function (…) {vart = Object.create(this); ... return t; } return T;}());Instantiate with: varx = <package>.T.create(…);The "type" object and the prototype are one! Differs from operator new, which equates the type with the constructor (prototype separate)Shared properties and methods go hereAssign theown propertieshere
  • 14. Root Types<package>.GameObject = (function () {varGameObject = {};GameObject.GameObject = GameObject;GameObject.create = function (id) {varg = Object.create(this);g.id = id; return g; }GameObject.update = function () {alert("Updating game object " + this.id); } return GameObject;}());Self reference will allow multiple levels of "super"Of course we are going to override this on the next slide
  • 15. Subtypes<package>.Projectile = (function () {var Projectile = Object.create(<package>.GameObject);Projectile.Projectile = Projectile;Projectile.create = function (id, name) {varp = <package>.GameObject.create.call(this, id);p.name = name; return p; }Projectile.update = function () { // override!this.GameObject.update.call(this);alert("Updating projectile " + this.name); } return Projectile;}());Note use of "this" instead of the package name – it shows we are using an ancestor type
  • 16. Subtypes, Slightly Cleaner<package>.Projectile = (function (supertype) {var Projectile = Object.create(supertype);Projectile.Projectile = Projectile;Projectile.create = function (id, name) {varp = supertype.create.call(this, id);p.name = name; return p; }Projectile.update = function () { // override!supertype.update.call(this);alert("Updating projectile " + this.name); } return Projectile;}(package.GameObject));Or mention an ancestor type directly
  • 17. How it all LooksPrivate data from closures not shown
  • 19. Why is this Useful?No extra scripts to includeNo framework to learn No need to say "new Base" and ".extend""Super" functionality is still available if neededProgrammer can apply the pattern selectivelyIt's real JavaScript Closures and Function.call are hardcoreMaintains prototypal feel, even though class-likeType.create()
  • 20. JavaScript Game EnginesThe Render EngineImpactAves (Zynga Germany)EffectIsogenicgameQueryRocket Engine (acquired by Disney)See engine lists and comparisons athttps://github.com/bebraw/jswiki/wiki/Game-Enginesandhttp://www.cssgalleries.com/2011/02/the-big-list-of-javascript-game-engines/
  • 21. SummaryGames benefit from an object-oriented, event-driven architectureMany approaches exist for modeling an OO software architecture in JavaScriptWe presented framework-free, engine independent modeling patternsPatterns were applied in a real HTML5, no-Flash application