Michael Birsak and Michael Hanzl
Institute of Computer Graphics and Algorithms
Vienna University of Technology
M. Birsak, M. Hanzl 2
Outline
MotivationRelated workGame descriptionImplementationPerformanceDemoFuture WorkConclusions
M. Birsak, M. Hanzl 3
Motivation
Develop and release a 3D gameGoogle AndroidOpenGL ES
Experiment with AndroidNOT a computer graphics demo!!!
M. Birsak, M. Hanzl 4
Related Work
Many 2D games (tiles)Basically no 3D game in Spring 2009Now: Some 3D games available
Android Knight (3D Chess game)Games from OmniGSoft:
Super-G StuntSnow Rally City Stage…
M. Birsak, M. Hanzl 5
Idea
Space Taxi for Commodore 64 (1984)Space Taxi 2 (2004)Some inofficial versions
M. Birsak, M. Hanzl 6
Game Overview
3D, but discrete height levels7 levels + 7 bonus levels3 lives & powerTransport passengers in 3 minutesScoreHighscore
M. Birsak, M. Hanzl 7
Game Objects
Transporter
Passenger
Terrorist
Asteroid
Geyser Bullet
Packet
Banana
M. Birsak, M. Hanzl 8
Controlling
Devices have different input unitsAccelerometer
CalibrationHow to ascend or descend?
SliderHeight depends on the velocity
M. Birsak, M. Hanzl 9
Implementation Overview
Collision DetectionView Frustum CullingModelloader (obj)LODEffectsRandom level generationOwn models & images & soundsSettingsLocal & Online Highscore
M. Birsak, M. Hanzl 10
Online HighscoreCompete against other usersOnly one entry per userRegistration requiredSearch for your own result
Local HighscoreCompare your own resultsDelete all entries
Highscore Features
View highscore on your Android deviceDetailed overview of the highscore entriesOverview of your result after insertCorrect handling of time zonesCorrect handling of ties
M. Birsak, M. Hanzl 11
Highscore Implementation
Local HighscoreSQLite
Online HighscoreInsert / Login / Register: HTTP Post (HTTPS!)Retrieve Data: HTTP / XMLWeb-Server: PHP / MySQL
Client Server
Android device Webserver
HTTP Post
Response
M. Birsak, M. Hanzl 12
Highscore Security
Avoid SQL-InjectionsCheck and constrain the user inputPHP escape function
Password → SHA-512 HashSecure connection (HTTPS)Check the highscore
Special „password“Check constraints:s-pt:22-pt:48-pt:17-pt:10-le:1-ti:28-b-b-le:1001-pk-pp-d-d-d
M. Birsak, M. Hanzl 13
Lifecycle
Activities could be interruptedActivity not killedActivity killed
Screen orientation changeLess memorySave / restore state
Do not block the main thread!Avoid injuries!!!
M. Birsak, M. Hanzl 14
Performance Issues
GeometryRasterizerCreating objects expensiveGarbage Collector (~100 - 300ms)Object Oriented Design
Function calls: local, via interface, JNILoading and parsing ASCII files is slow
M. Birsak, M. Hanzl 15
Performance Solution
Reuse your objects → Object PoolTry to avoid garbage
Concatenated Strings / Java built-in methods!Invoke Garbage Collector manually
Decrease the number of polygons to renderUse the draw_texture extensionUse Java Object Serialization for model loadingWrite code that is fast
Reference: Chris Pruett: Writing Real Time Games For Android, Google IO 09, May 2009
M. Birsak, M. Hanzl 16
Performance
G1: 20 - 30 FPSEmulator: 10 - 20 FPS (Dual Core 2x3Ghz)Models: 18 - 508 / 372 triangles
push(1000)
pop(1000)
0 5 10 15 20 25 30
16.68
2.59
26.66
5.82
Stacks G1
Stack StStack
Time [ms]
iterate(10000)
remove(100, 1000)
add(1000)
0 20 40 60 80 100 120
21.75
101.27
17.63
16.4
107.99
21.56
34.02
Lists G1
LinkedList ArrayList StLinkedList
Time [ms]
M. Birsak, M. Hanzl 17
Demo
M. Birsak, M. Hanzl 18
Skills and Benefits
Controlling the game is not easy!Measuring distancesSpatial imaginationFind strategies very quicklyBalance between speed and scoreTrust in luckWork under stress
M. Birsak, M. Hanzl 19
Future work
Save the gameHighscore searchObjects
Planets / sunsSpaceships (enemies)
EffectsLens Flare
M. Birsak, M. Hanzl 20
Conclusions: Android
Permanent further developmentLicense: „Free“Easy to write applications, but…Great tools, examples, community, guidelinesOpenGL ES support not perfectDifferent hardware (currently ~11 smartphones)
Different display resolutionsDifferent input unitsPerformance
Emulator ǂ Real Device
M. Birsak, M. Hanzl 21
The END
Thank you for your attentionSpecial thanks to Peter Rautek & the instituteAre there any questions?