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

fansbutterflyMobile - Wireless

Jul 19, 2012 (5 years and 4 months ago)

348 views

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

Read my tutorial on Android at
http://www.
cs.tufts.edu/comp/50GD/lectures/tut1chow-
FINAL.pdf

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
client-
side
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

Example:
http://www.eecs.tufts.
edu/~mbfrey/comp120/a1/frogger.html
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

More:
http://www.andymcm.com/csharpfaq.htm
XNA 4: The Game Loop (In General)
Initialize();
LoadGraphicsContent();
while (stillPlaying)
{
Update();
Draw();
}
UnloadGraphicsContent();
XNA 4: Basic Code
1.
The starting point:
http://www.cs.tufts.
edu/comp/50GD/lectures/Program.cs
2.
The game class:
http://www.cs.tufts.
edu/comp/50GD/lectures/Game1.cs

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/en-
us/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?
Android Resources

http://developer.android.com/sdk/index.html

http://www.javacodegeeks.
com/2011/07/android-game-development-
create-project.html

http://android-developers.blogspot.
com/2010/06/game-development-for-
android-quick.html

http://code.google.com/p/androidinvaders/
HTML5 Resources

http://www.html5rocks.com/en/

http://html5games.com/

HTML5 games from COMP 120: Web
Engineering Fall 2011,
http://www.cs.tufts.
edu/comp/120/assignments/a1.php

COMP 20,
http://www.cs.tufts.edu/comp/20/
XNA 4 Resources

Your first game tutorial:
http://msdn.
microsoft.com/en-us/library/bb203893
(v=xnagamestudio.40).aspx

http://msdn.microsoft.com/en-
us/library/bb203894(v=xnagamestudio.40).
aspx

https://www.dreamspark.com/
http://rbwhitaker.wikidot.com/xna-tutorials