SlideShare uma empresa Scribd logo
1 de 16
Cross-Platform 
Software Design 
Michael Henson 
Professor 
College of Engineering and Information Sciences 
mhenson@devry.edu 
/arachnojava 
@arachnojava 
+MichaelHenson /michaeljhenson 
Arachnojava mhframework.blogspot.com
The Problems 
• Professional developers need to: 
– Reach the maximum number of customers. 
– Keep current with new computing devices. 
• Students need to: 
– Quickly adapt to the technologies that will grab 
the attention of potential employers. 
– Increase the probability that a potential employer 
will be able to evaluate their work. 
• Wouldn’t it be nice if we could develop 
just one product and make it available 
for a variety of computing devices? 
– PC, tablet, smart phone, game console, etc.
One Possible Solution 
1. Identify parts that are same across platforms. 
– We’ll call this the core functionality. 
2. Encapsulate the parts that differ. 
– We’ll call this the platform layer. 
3. Create an interface to the platform layer that can 
be repeated for all supported platforms. 
4. Make sure the core only talks to the platform 
layer interface and not the actual platform. 
– Then we can swap platforms and the core never 
needs to know!
A Bird’s-Eye 
View of the 
Idea
Proof of Concept: Snow vs. Man 
• Very early prototype built with 
MHFramework game engine which 
implements this design. 
• Play it on my laptop, tablet, or phone. 
• Objective: Prevent the evil snowmen 
from extinguishing your campfire. 
• How to Play: Click (tap) on open spaces 
to place defensive turrets.
Systems That Can 
(or Will) Run My Game 
Android 
Phone 
Android 
Tablet 
OUYA Game 
Console 
M.O.J.O. Game 
Console 
Linux 
Mac OS 
Windows
So…How Does It Work? 
1. The main program runs in a platform-specific 
context. 
– For instance, an Activity on Android or a JFrame 
on Windows. 
2. The program requests the appropriate 
platform layer depending on the context. 
3. All calls to the platform go through a 
common interface that handles 
communication with whatever platform lies 
beneath.
Main Program Code 
Notice the major similarities (and minor differences) between 
the PC and Android launchers for Snow vs. Man. 
PC Version 
public static void main(String[] args) 
{ 
// Create the game's start screen. 
MHScreen startingScreen = new SVMMainMenuScreen(); 
// Configure video settings. 
MHVideoSettings displaySettings = new MHVideoSettings(); 
displaySettings.windowCaption = "Snow Vs. Man"; 
displaySettings.displayWidth = 800; 
displaySettings.displayHeight = 480; 
// Launch the game. 
MHPCPlatform.run(new JFrame(), 
startingScreen, displaySettings); 
} 
Android Version 
protected void onCreate(Bundle savedInstanceState) 
{ 
// Initialize the Android activity. 
super.onCreate(savedInstanceState); 
// Create the game's start screen. 
MHScreen startingScreen = new SVMMainMenuScreen(); 
// Configure video settings. 
MHVideoSettings displaySettings = new MHVideoSettings(); 
displaySettings.windowCaption = "Snow Vs. Man"; 
displaySettings.displayWidth = 800; 
displaySettings.displayHeight = 480; 
// Launch the game. 
MHAndroidPlatform.run(this, 
startingScreen, displaySettings); 
}
A Common Interface For All 
Platforms 
Since every platform interface will have these same 
functions, the game can call them without caring which 
platform is performing the tasks behind the scenes. 
public interface MHPlatformFactory 
{ 
public MHBitmapImage createImage(int width, int height); 
public MHBitmapImage createImage(String filename); 
public MHColor createColor(int r, int g, int b, int a); 
public MHSoundManager getSoundManager(); 
public MHFont createFont(String fontName); 
public MHKeyCodes getKeyCodes(); 
public String getAssetsDirectory(); 
public MHTextFile openTextFile(String filename, Mode mode); 
}
The Technical Stuff 
for Nerds
The Guiding Object-Oriented 
Design Principles 
• Separate the aspects that vary from the aspects that stay 
the same. 
– The platform varies while the game code stays the same. 
• Strive for loosely coupled designs between objects that 
interact. 
– The common interface makes it easy to swap one platform for 
another without affecting the game code. 
• The Principle of Least Knowledge: “Talk only to your 
immediate friends.” 
– Minimizes places where game depends on platform. 
• The Hollywood Principle: “Don’t call us, we’ll call you.” 
– The platform serves the game, never vice versa.
The Design Patterns That 
Make This Possible 
• Façade Pattern 
– Makes the platform easier to use by hiding its complexity. 
• Strategy Pattern 
– The game engine only supports elements of the platform 
on which it is running. Few wasted resources, no 
extraneous conditional logic. 
• Singleton Pattern 
– Ensures single platform layer and provides access to it. 
• Template Method Pattern 
– Allows for the possibility that some functions may be the 
same across platforms while others may differ.
• Adapter Pattern 
– Each platform may have different ways of handling 
graphics, input, audio, etc. Adapter makes them all 
look the same from the game’s point of view. 
• Observer Pattern 
– Allows input handlers to use a generic set of events 
independent of those generated by the platforms. 
• Abstract Factory Pattern 
– Handles the details of creating the correct objects 
(graphics, sounds, etc.) for each platform.
Drawbacks To This Approach 
• Platform-specific advantages may be lost. 
– Example: A mouse cannot multi-touch, while touch 
screens cannot right-click. 
• The extra level of abstraction may degrade 
runtime performance. 
• The platform layer adds unavoidable 
complexity to the software architecture. 
Software development involves trade-offs at every step. We 
must always consider the pros and cons of any solution.
References 
Freeman, E. (2004). Head First design patterns. Sebastopol, CA: 
O'Reilly. 
Gamma, E. (1995). Design patterns: elements of reusable object-oriented 
software. Reading, Mass.: Addison-Wesley. 
Gregory, J. (2009). Game engine architecture. Wellesley, Mass.: A K 
Peters. 
Henson, M. (2013, July 24). Class structure of the platform layer. 
Retrieved June 20, 2014, from 
http://mhframework.blogspot.com/2013/07/class-structure-of-platform- 
layer.html 
Pressman, R. S. (2010). Software engineering: a practitioner's 
approach (7th ed.). Boston, Mass.: McGraw-Hill.

Mais conteúdo relacionado

Mais procurados

문석진, 프로젝트DH의 절차적 애니메이션 시스템 Ⅱ, NDC2018
문석진, 프로젝트DH의 절차적 애니메이션 시스템 Ⅱ, NDC2018문석진, 프로젝트DH의 절차적 애니메이션 시스템 Ⅱ, NDC2018
문석진, 프로젝트DH의 절차적 애니메이션 시스템 Ⅱ, NDC2018
devCAT Studio, NEXON
 

Mais procurados (20)

CS 354 GPU Architecture
CS 354 GPU ArchitectureCS 354 GPU Architecture
CS 354 GPU Architecture
 
A frameハンズオン 20170129
A frameハンズオン 20170129A frameハンズオン 20170129
A frameハンズオン 20170129
 
「原神」におけるコンソールプラットフォーム開発
「原神」におけるコンソールプラットフォーム開発「原神」におけるコンソールプラットフォーム開発
「原神」におけるコンソールプラットフォーム開発
 
ここがつらいよ8thwall
ここがつらいよ8thwallここがつらいよ8thwall
ここがつらいよ8thwall
 
Node canvasで作るプロトタイプ
Node canvasで作るプロトタイプNode canvasで作るプロトタイプ
Node canvasで作るプロトタイプ
 
셰이더가 뭐에요?
셰이더가 뭐에요?셰이더가 뭐에요?
셰이더가 뭐에요?
 
Unlocking cross selling in travel
Unlocking cross selling in travel Unlocking cross selling in travel
Unlocking cross selling in travel
 
良くわかるMeta
良くわかるMeta良くわかるMeta
良くわかるMeta
 
【Unity道場スペシャル 2017博多】TextMesh Pro を使いこなす
【Unity道場スペシャル 2017博多】TextMesh Pro を使いこなす【Unity道場スペシャル 2017博多】TextMesh Pro を使いこなす
【Unity道場スペシャル 2017博多】TextMesh Pro を使いこなす
 
언리얼엔진4를 활용한 레이트레이싱 리얼타임 영상 제작하기
언리얼엔진4를 활용한 레이트레이싱 리얼타임 영상 제작하기언리얼엔진4를 활용한 레이트레이싱 리얼타임 영상 제작하기
언리얼엔진4를 활용한 레이트레이싱 리얼타임 영상 제작하기
 
Hair in Tomb Raider
Hair in Tomb RaiderHair in Tomb Raider
Hair in Tomb Raider
 
Ride Sharing Service in Bangladesh.pptx
Ride Sharing Service in Bangladesh.pptxRide Sharing Service in Bangladesh.pptx
Ride Sharing Service in Bangladesh.pptx
 
A-Frameで始めるOculus Quest対応WebVR
A-Frameで始めるOculus Quest対応WebVRA-Frameで始めるOculus Quest対応WebVR
A-Frameで始めるOculus Quest対応WebVR
 
문석진, 프로젝트DH의 절차적 애니메이션 시스템 Ⅱ, NDC2018
문석진, 프로젝트DH의 절차적 애니메이션 시스템 Ⅱ, NDC2018문석진, 프로젝트DH의 절차적 애니메이션 시스템 Ⅱ, NDC2018
문석진, 프로젝트DH의 절차적 애니메이션 시스템 Ⅱ, NDC2018
 
MAYAで作ったアニメーションをUnityに取り込んで動かしてみるの巻
MAYAで作ったアニメーションをUnityに取り込んで動かしてみるの巻MAYAで作ったアニメーションをUnityに取り込んで動かしてみるの巻
MAYAで作ったアニメーションをUnityに取り込んで動かしてみるの巻
 
VRM 標準シェーダ MToon の使い方
VRM 標準シェーダ MToon の使い方VRM 標準シェーダ MToon の使い方
VRM 標準シェーダ MToon の使い方
 
ゲームの仕様書を書こうまとめ
ゲームの仕様書を書こうまとめゲームの仕様書を書こうまとめ
ゲームの仕様書を書こうまとめ
 
ゲームにおけるニューラルネットワーク「NERO における学習と進化 」(後半)
ゲームにおけるニューラルネットワーク「NERO における学習と進化 」(後半)ゲームにおけるニューラルネットワーク「NERO における学習と進化 」(後半)
ゲームにおけるニューラルネットワーク「NERO における学習と進化 」(後半)
 
【Unite Tokyo 2019】トヨタのxR活用事例ご紹介
【Unite Tokyo 2019】トヨタのxR活用事例ご紹介【Unite Tokyo 2019】トヨタのxR活用事例ご紹介
【Unite Tokyo 2019】トヨタのxR活用事例ご紹介
 
テクニカルアーティストの仕事とスキル ~パイプライン系TAの事例~
テクニカルアーティストの仕事とスキル ~パイプライン系TAの事例~テクニカルアーティストの仕事とスキル ~パイプライン系TAの事例~
テクニカルアーティストの仕事とスキル ~パイプライン系TAの事例~
 

Destaque

Climate change
Climate changeClimate change
Climate change
figgie11
 

Destaque (10)

Kerala-God's Own Country
Kerala-God's Own CountryKerala-God's Own Country
Kerala-God's Own Country
 
Urban Health and Resilience in the Lagos Metropolis ( A Presentation By Ebele...
Urban Health and Resilience in the Lagos Metropolis ( A Presentation By Ebele...Urban Health and Resilience in the Lagos Metropolis ( A Presentation By Ebele...
Urban Health and Resilience in the Lagos Metropolis ( A Presentation By Ebele...
 
Pengenalan dbase IV
Pengenalan dbase IVPengenalan dbase IV
Pengenalan dbase IV
 
DEVNET-1129 WAN Automation Engine - Develop Traffic Aware Applications Using ...
DEVNET-1129	WAN Automation Engine - Develop Traffic Aware Applications Using ...DEVNET-1129	WAN Automation Engine - Develop Traffic Aware Applications Using ...
DEVNET-1129 WAN Automation Engine - Develop Traffic Aware Applications Using ...
 
Climate change
Climate changeClimate change
Climate change
 
Fullah sugah collection aw 2015 bags
Fullah sugah collection aw 2015 bagsFullah sugah collection aw 2015 bags
Fullah sugah collection aw 2015 bags
 
DEVNET-1164 Using OpenDaylight for Notification Driven Workflows
DEVNET-1164	Using OpenDaylight for Notification Driven WorkflowsDEVNET-1164	Using OpenDaylight for Notification Driven Workflows
DEVNET-1164 Using OpenDaylight for Notification Driven Workflows
 
Perangkat Lunak
Perangkat LunakPerangkat Lunak
Perangkat Lunak
 
DEVNET-1147 Energizing Your Career with Cloud Technologies
DEVNET-1147	Energizing Your Career with Cloud TechnologiesDEVNET-1147	Energizing Your Career with Cloud Technologies
DEVNET-1147 Energizing Your Career with Cloud Technologies
 
Creating and managing a non-profit ( A Presentation By Ebele Mogo, DrPH)
Creating and managing a non-profit ( A Presentation By Ebele Mogo, DrPH)Creating and managing a non-profit ( A Presentation By Ebele Mogo, DrPH)
Creating and managing a non-profit ( A Presentation By Ebele Mogo, DrPH)
 

Semelhante a Cross-Platform Software Design

Game programming workshop
Game programming workshopGame programming workshop
Game programming workshop
narigadu
 
Mdc2010 Casual Game Dev
Mdc2010 Casual Game DevMdc2010 Casual Game Dev
Mdc2010 Casual Game Dev
momobangalore
 
Btec assignment-brief unit-20 assignment 2
Btec assignment-brief unit-20 assignment 2Btec assignment-brief unit-20 assignment 2
Btec assignment-brief unit-20 assignment 2
thomasmcd6
 
Assignment instructions
Assignment instructionsAssignment instructions
Assignment instructions
wallinplanet
 
Distributed load testing (Local vs Cloud)
Distributed load testing (Local vs Cloud)Distributed load testing (Local vs Cloud)
Distributed load testing (Local vs Cloud)
TestCampRO
 
Project Report Tron Legacy
Project Report Tron LegacyProject Report Tron Legacy
Project Report Tron Legacy
Manpreet Singh
 

Semelhante a Cross-Platform Software Design (20)

Introduction to Game Engine: Concepts & Components
Introduction to Game Engine: Concepts & ComponentsIntroduction to Game Engine: Concepts & Components
Introduction to Game Engine: Concepts & Components
 
Delta Engine @ CeBit 2011
Delta Engine @ CeBit 2011Delta Engine @ CeBit 2011
Delta Engine @ CeBit 2011
 
Operating Systems
Operating SystemsOperating Systems
Operating Systems
 
Creating Casual Games for Windows 8
Creating Casual Games for Windows 8Creating Casual Games for Windows 8
Creating Casual Games for Windows 8
 
Game programming workshop
Game programming workshopGame programming workshop
Game programming workshop
 
Mdc2010 Casual Game Dev
Mdc2010 Casual Game DevMdc2010 Casual Game Dev
Mdc2010 Casual Game Dev
 
Creating Multiscreen Apps using Adobe Flash Platform
Creating Multiscreen Apps using Adobe Flash PlatformCreating Multiscreen Apps using Adobe Flash Platform
Creating Multiscreen Apps using Adobe Flash Platform
 
Btec assignment-brief unit-20 assignment 2
Btec assignment-brief unit-20 assignment 2Btec assignment-brief unit-20 assignment 2
Btec assignment-brief unit-20 assignment 2
 
Introduction to html5 game programming with impact js
Introduction to html5 game programming with impact jsIntroduction to html5 game programming with impact js
Introduction to html5 game programming with impact js
 
Presentación Unity
Presentación UnityPresentación Unity
Presentación Unity
 
Assignment instructions
Assignment instructionsAssignment instructions
Assignment instructions
 
Distributed load testing (Local vs Cloud)
Distributed load testing (Local vs Cloud)Distributed load testing (Local vs Cloud)
Distributed load testing (Local vs Cloud)
 
1-Introduction (Game Design and Development)
1-Introduction (Game Design and Development)1-Introduction (Game Design and Development)
1-Introduction (Game Design and Development)
 
Casual Engines 2009
Casual Engines 2009Casual Engines 2009
Casual Engines 2009
 
HTML5 Game Development frameworks overview
HTML5 Game Development frameworks overviewHTML5 Game Development frameworks overview
HTML5 Game Development frameworks overview
 
Cross Platform Game Programming with Cocos2d-js
Cross Platform Game Programming with Cocos2d-jsCross Platform Game Programming with Cocos2d-js
Cross Platform Game Programming with Cocos2d-js
 
Week Four - Operating Systems
Week Four - Operating SystemsWeek Four - Operating Systems
Week Four - Operating Systems
 
Game design & development
Game design & developmentGame design & development
Game design & development
 
Less code More fun
Less code More funLess code More fun
Less code More fun
 
Project Report Tron Legacy
Project Report Tron LegacyProject Report Tron Legacy
Project Report Tron Legacy
 

Último

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Último (20)

Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 

Cross-Platform Software Design

  • 1. Cross-Platform Software Design Michael Henson Professor College of Engineering and Information Sciences mhenson@devry.edu /arachnojava @arachnojava +MichaelHenson /michaeljhenson Arachnojava mhframework.blogspot.com
  • 2. The Problems • Professional developers need to: – Reach the maximum number of customers. – Keep current with new computing devices. • Students need to: – Quickly adapt to the technologies that will grab the attention of potential employers. – Increase the probability that a potential employer will be able to evaluate their work. • Wouldn’t it be nice if we could develop just one product and make it available for a variety of computing devices? – PC, tablet, smart phone, game console, etc.
  • 3. One Possible Solution 1. Identify parts that are same across platforms. – We’ll call this the core functionality. 2. Encapsulate the parts that differ. – We’ll call this the platform layer. 3. Create an interface to the platform layer that can be repeated for all supported platforms. 4. Make sure the core only talks to the platform layer interface and not the actual platform. – Then we can swap platforms and the core never needs to know!
  • 4. A Bird’s-Eye View of the Idea
  • 5. Proof of Concept: Snow vs. Man • Very early prototype built with MHFramework game engine which implements this design. • Play it on my laptop, tablet, or phone. • Objective: Prevent the evil snowmen from extinguishing your campfire. • How to Play: Click (tap) on open spaces to place defensive turrets.
  • 6. Systems That Can (or Will) Run My Game Android Phone Android Tablet OUYA Game Console M.O.J.O. Game Console Linux Mac OS Windows
  • 7. So…How Does It Work? 1. The main program runs in a platform-specific context. – For instance, an Activity on Android or a JFrame on Windows. 2. The program requests the appropriate platform layer depending on the context. 3. All calls to the platform go through a common interface that handles communication with whatever platform lies beneath.
  • 8. Main Program Code Notice the major similarities (and minor differences) between the PC and Android launchers for Snow vs. Man. PC Version public static void main(String[] args) { // Create the game's start screen. MHScreen startingScreen = new SVMMainMenuScreen(); // Configure video settings. MHVideoSettings displaySettings = new MHVideoSettings(); displaySettings.windowCaption = "Snow Vs. Man"; displaySettings.displayWidth = 800; displaySettings.displayHeight = 480; // Launch the game. MHPCPlatform.run(new JFrame(), startingScreen, displaySettings); } Android Version protected void onCreate(Bundle savedInstanceState) { // Initialize the Android activity. super.onCreate(savedInstanceState); // Create the game's start screen. MHScreen startingScreen = new SVMMainMenuScreen(); // Configure video settings. MHVideoSettings displaySettings = new MHVideoSettings(); displaySettings.windowCaption = "Snow Vs. Man"; displaySettings.displayWidth = 800; displaySettings.displayHeight = 480; // Launch the game. MHAndroidPlatform.run(this, startingScreen, displaySettings); }
  • 9. A Common Interface For All Platforms Since every platform interface will have these same functions, the game can call them without caring which platform is performing the tasks behind the scenes. public interface MHPlatformFactory { public MHBitmapImage createImage(int width, int height); public MHBitmapImage createImage(String filename); public MHColor createColor(int r, int g, int b, int a); public MHSoundManager getSoundManager(); public MHFont createFont(String fontName); public MHKeyCodes getKeyCodes(); public String getAssetsDirectory(); public MHTextFile openTextFile(String filename, Mode mode); }
  • 10.
  • 11. The Technical Stuff for Nerds
  • 12. The Guiding Object-Oriented Design Principles • Separate the aspects that vary from the aspects that stay the same. – The platform varies while the game code stays the same. • Strive for loosely coupled designs between objects that interact. – The common interface makes it easy to swap one platform for another without affecting the game code. • The Principle of Least Knowledge: “Talk only to your immediate friends.” – Minimizes places where game depends on platform. • The Hollywood Principle: “Don’t call us, we’ll call you.” – The platform serves the game, never vice versa.
  • 13. The Design Patterns That Make This Possible • Façade Pattern – Makes the platform easier to use by hiding its complexity. • Strategy Pattern – The game engine only supports elements of the platform on which it is running. Few wasted resources, no extraneous conditional logic. • Singleton Pattern – Ensures single platform layer and provides access to it. • Template Method Pattern – Allows for the possibility that some functions may be the same across platforms while others may differ.
  • 14. • Adapter Pattern – Each platform may have different ways of handling graphics, input, audio, etc. Adapter makes them all look the same from the game’s point of view. • Observer Pattern – Allows input handlers to use a generic set of events independent of those generated by the platforms. • Abstract Factory Pattern – Handles the details of creating the correct objects (graphics, sounds, etc.) for each platform.
  • 15. Drawbacks To This Approach • Platform-specific advantages may be lost. – Example: A mouse cannot multi-touch, while touch screens cannot right-click. • The extra level of abstraction may degrade runtime performance. • The platform layer adds unavoidable complexity to the software architecture. Software development involves trade-offs at every step. We must always consider the pros and cons of any solution.
  • 16. References Freeman, E. (2004). Head First design patterns. Sebastopol, CA: O'Reilly. Gamma, E. (1995). Design patterns: elements of reusable object-oriented software. Reading, Mass.: Addison-Wesley. Gregory, J. (2009). Game engine architecture. Wellesley, Mass.: A K Peters. Henson, M. (2013, July 24). Class structure of the platform layer. Retrieved June 20, 2014, from http://mhframework.blogspot.com/2013/07/class-structure-of-platform- layer.html Pressman, R. S. (2010). Software engineering: a practitioner's approach (7th ed.). Boston, Mass.: McGraw-Hill.

Notas do Editor

  1. Consider recreating a cleaner and less physical draft of this diagram. Show that the game code plugs into the MHFramework class. Add colored annotations to point out design patterns in use. Façade – MHPlatform Strategy – MHPlatform Singleton – MHPlatform Template Method – MHGameApplication Abstract Factory – MHPlatformFactory Adapter – MHBitmapImage, MHGraphicsCanvas Observer – MHInputEventHandler
  2. Remove the “Continued” note when printing for poster.