Game Development with the Android SDK vs. XNA vs. HTML5

Game Development with the
Android SDK vs. XNA vs. HTML5
Ming Chow
Tufts OpenCourseWare
Introduction to Game Development
Spring 2012
Game Development
with the Android
SDK vs. XNA vs.
HTML5
Ming Chow
The Purpose of Your Final Project
● Develop a game on a real platform
● But why?
Factors
● Memory limitations
● Display capabilities (from low-res to HD)
● User input that does not include keyboard or mouse
●
●
●
●
●
●
●
(touch, multi-touch, controllers, mouse)
Internet access
Usage fees (especially for mobile)
Built-in capabilities (phone, GPS, camera, Kinect)
Micropayment (Xbox Live, iTunes App Store)
Services (e.g., Push Notification, In-Game Notification)
Multitasking
Concurrency (multi-core processors)
Java
●
●
●
●
●
●
●
●
●
●
●
Both a compiled and interpreted language
Source code looks very similar to C++
Everything in Java is object-oriented
Strongly-typed language
No pointers
Memory leaks are prevented by automatic garbage collection in Java
No structs
There is no such thing as a main program
Has a String type
Supports a true boolean
A semicolon (';') is not required to close a class definition
Android for Games
● See my Android tutorial material at https:
//github.
com/tuftsdev/WebEngineering/tree/master/a
ndroid
● Hardly any framework to write games
● Want to build a game from scratch? You
have to write your own game loop and even
timer code.
The Good, The Bad, The (Very) Ugly
with Android and Java
● The good: portability, no draconian process
to put apps onto Google Play (formerly
known as the Android Market)
● The bad: Java is still slower than C; legal
issues between Oracle and Java cloud the
ecosystem; lack of game frameworks
● The very ugly: fragmentation of devices;
many app markets
HTML5
● Not just a markup language but is a clientside stack of three languages:
○ HTML - the markup language
○ Cascading Style Sheet (CSS) - for presentation (i.e.,
design and layout)
○ JavaScript - for interactivity
The Browser as a Game Platform
● Being pushed heavily by Google as evident
with Chrome
● Many APIs
● Creating a game:
○ Sprite sheets
○ JavaScript <canvas>
○ setInterval(code, millisec) for game loop
The Good, The Bad, The (Very) Ugly
with HTML5 for Games
The good: cross-platform
The bad: too new; every major player (Google,
Apple, Microsoft, etc.) is playing their own
HTML5 game
The very ugly: browser-incompatibilities galore!
Run http://html5test.com/ on your browser (and
then compare result with others)
C#
●
●
●
●
●
●
●
●
Loosely based on C++; very similar to Java
Object-oriented
Managed environment
Like Java, there is automatic garbage collection
Array bounds checking
No header files, includes or forward declarations necessary
No semicolon after a class declaration in C#
Everything derives from object
XNA 4: The Game Loop (In General)
Initialize();
LoadGraphicsContent();
while (stillPlaying)
{
Update();
Draw();
}
UnloadGraphicsContent();
XNA 4: The Content Pipeline
● A process once content is added to Content
of project
● Flexible
● The input: some game asset in some format
(e.g., artwork)
● The output: a compiled asset
● Why? For building, loading, and optimizing
various forms of content
● Diagram: http://msdn.microsoft.com/enus/library/bb447745.aspx
The Good, The Bad, The Ugly with
XNA 4 for Games
The good: some portability; excellent APIs -many critical elements such as a sprite class
and the game loop already provided
The bad: many dependencies (from .NET
libraries to Visual Studio); C# is slower than C;
very little low-level access unlike the real Xbox
dev kit; size restriction
The ugly: the indie game store on Xbox Live...
The Great Debate
● What would I choose?