Tools for Android GamesRaul Portales@sla_shalafi          @thepilltreeraul@plattysoft.com   http://thepilltree.com
Summary●   Introduction to game development●   Engines       ●   AndEngine       ●   jPCT-AE●   Scores / Achievements●   M...
Game Architecture (Simplified)               Game Engine Draw Thread   Game Objects   Update Thread
Performance Tips●   Avoid object creations       ●   Use pools and pre create them●   Avoid getters and setters       ●   ...
Why use OpenGL?   Performance
Why use OpenGL?   Performance
Why use any EngineYou don’t want to start from scratch
AndEngine
AndEngine●   http://www.andengine.org/●   2D Graphics Engine●   LGPL●   Extensions       ●   Physics Engine (Box2D)       ...
Games built with AndEngine●   Chalk Ball●   Bunny Shooter●   Greedy Spiders●   Wheelz●   Farm Tower●   ...
Games built with AndEngine
Project setup●   Put the jar under libs        ●   Add them to the build             path●   Don’t forget “armeabi”●   Get...
Concepts●   Engine●   Scene       ●   Sprites + Handlers●   Texture / Texture Atlas●   Sprite●   Body       ●   Fixture
Game Architecture / AndEngine                Game Engine  Draw Thread   Game Objects   Update Thread                   Sce...
Activity creation flow●   BaseGameActivity       ●   onLoadEngine       ●   onLoadResources       ●   onLoadScene       ● ...
Creating the Engine (1/2)public Engine onLoadEngine() {DisplayMetrics om = new DisplayMetrics();getWindowManager().getDefa...
Creating the Engine (2/2)EngineOptions options = new EngineOptions(true,ScreenOrientation.LANDSCAPE, rrp, camera);options....
Loading Resourcespublic void onLoadResources() {BitmapTextureAtlas bitmapTextureAtlas = newBitmapTextureAtlas(64, 64,Textu...
Texture Atlas●   Quite a pain for AndEngine       ●   Built by hand       ●   Size must be a power of 2       ●   One big ...
Creating the Scene (1/3)public Scene onLoadScene() {Scene scene = new Scene();PhysicsWorld physicsWorld = new PhysicsWorld...
Creating the Scene (2/3)Sprite box = new Sprite(0, 0, mBoxTextureRegion);FixtureDef boxFixture =PhysicsFactory.createFixtu...
Creating the Scene (3/3)scene.registerUpdateHandler(physicsWorld);scene.registerUpdateHandler(mUpdateHandler);return scene;}
Types of bodies●   Dynamic        ●   It is affected by physics like gravity●   Kinematic        ●   It moves in a specifi...
More Interesting things●   TiledTextures / Animated Sprites●   Animations●   Sound Engine●   Particle Systems●   Collision...
Intermission     ← AndEngine Example apk
jPCT-AE
jPCT-AE●   http://www.jpct.net/jpct-ae/●   3D Engine        ●   3DObjects        ●   Lights        ●   etc●   No physics  ...
Games built with jPCT-AE●   SpaceCat●   SkyFrontier●   Forgotten Elements●   Mobialia Chess●   Freddy Budgett●   Alien Run...
Games built with jPCT-AE
Project setupAdd jpct-ae.jar to libs / Build path
Concepts / Classes●   Renderer / FrameBuffer●   World●   Texture / TextureManager●   Object3D●   Light●   Camera
Game Architecture / jPCT-AE              Game EngineDraw Thread   Game Objects   Update Thread Renderer        World      ...
Preparing the GLSurfaceViewmGlView = (GLSurfaceView) findViewById(R.id.glview);mGlView.setKeepScreenOn(true);mViewRenderer...
Renderer setuppublic void onDrawFrame(GL10 gl) {    buffer.clear(back);    synchronized (mWorld) {        mWorld.renderSce...
Setup the WorldmWorld = new World();mWorld.setAmbientLight(150, 150, 150);
Loading TexturesResources res = getResources();Texture texture =   new Texture(res.getDrawable(R.raw.texture));TextureMana...
Loading ObjectsmModel = Loader.load3DS(getResources()   .openRawResource(R.raw.model), 1)[0];mModel.setTexture("texture");...
Creating LightsLight sun = new Light(mWorld);sun.setIntensity(250, 250, 250);SimpleVector sv = new SimpleVector(0, -100, -...
Handling the cameraCamera cam = mWorld.getCamera();cam.setPosition(new SimpleVector(0, 0,-100));cam.lookAt(mModel.getTrans...
More about the camera●   It has a position        ●   Camera.setPosition●   It has a target        ●   Camera.lookAt●   It...
The 3D axis
Operations with objects●   Hierarchy       ●   addChild●   Move       ●   setPosition / translate●   Rotation       ●   ro...
More Interesting Things●   Keyframe Animations●   Collision detect (Ellipsoids)●   Billboards●   Transparency●   Culling● ...
And a workaround●   Overlay native layouts       ●   Menus       ●   Dialogs
Another Intermission          ← jPCT-AE Example apk
Bonus: Other Engines●   PlayN       ●    https://developers.google.com/playn/●   NME       ●    http://www.haxenme.org/●  ...
Scores / Achievements
Why use a Library?●   Not reinventing the wheel        ●   It is proven that works●   Familiarity for users        ●   Oth...
Available libraries●   ScoreLoop        ●   OpenFeint
What do you get?●   Achievements       ●   Not very impressive●   Leaderboards       ●   That is interesting●   News Feed●...
Easy to integrate●   Android Library Project●   Initialize with the Application●   Open a specific screen        ●   2 lin...
MonetizationToo much to say for a single slide
And now...●   Lunch●   Pitch your game idea       ●   Gather a team●   Hackaton●   Demos, Pizza & Beer
Tools for Android GamesRaul Portales@sla_shalafi          @thepilltreeraul@plattysoft.com   http://thepilltree.com
Upcoming SlideShare
Loading in …5
×

Tools for developing Android Games

7,875 views

Published on

Slides from the workshop: Tools for developing Android Games, held on March 24th, 2012 at Amsterdam.

Published in: Technology, Design
  • Be the first to comment

Tools for developing Android Games

  1. 1. Tools for Android GamesRaul Portales@sla_shalafi @thepilltreeraul@plattysoft.com http://thepilltree.com
  2. 2. Summary● Introduction to game development● Engines ● AndEngine ● jPCT-AE● Scores / Achievements● Monetization systems
  3. 3. Game Architecture (Simplified) Game Engine Draw Thread Game Objects Update Thread
  4. 4. Performance Tips● Avoid object creations ● Use pools and pre create them● Avoid getters and setters ● Public attributes instead● Avoid collections● Avoid interfaces● Use a single Activity
  5. 5. Why use OpenGL? Performance
  6. 6. Why use OpenGL? Performance
  7. 7. Why use any EngineYou don’t want to start from scratch
  8. 8. AndEngine
  9. 9. AndEngine● http://www.andengine.org/● 2D Graphics Engine● LGPL● Extensions ● Physics Engine (Box2D) ● Live Wallpapers ● etc
  10. 10. Games built with AndEngine● Chalk Ball● Bunny Shooter● Greedy Spiders● Wheelz● Farm Tower● ...
  11. 11. Games built with AndEngine
  12. 12. Project setup● Put the jar under libs ● Add them to the build path● Don’t forget “armeabi”● Get the source ● Import project ● Create res dir
  13. 13. Concepts● Engine● Scene ● Sprites + Handlers● Texture / Texture Atlas● Sprite● Body ● Fixture
  14. 14. Game Architecture / AndEngine Game Engine Draw Thread Game Objects Update Thread Scene UpdateHandler Sprites
  15. 15. Activity creation flow● BaseGameActivity ● onLoadEngine ● onLoadResources ● onLoadScene ● onLoadComplete
  16. 16. Creating the Engine (1/2)public Engine onLoadEngine() {DisplayMetrics om = new DisplayMetrics();getWindowManager().getDefaultDisplay().getMetrics(om);camWidth = 480;camHeight = (int) (om.heightPixels*480f / om.widthPixels);RatioResolutionPolicy rrp = newRatioResolutionPolicy(camWidth, camHeight);Camera camera = new Camera(0, 0, camWidth, camHeight);
  17. 17. Creating the Engine (2/2)EngineOptions options = new EngineOptions(true,ScreenOrientation.LANDSCAPE, rrp, camera);options.getRenderOptions().disableExtensionVertexBufferObjects();return new Engine(options);}
  18. 18. Loading Resourcespublic void onLoadResources() {BitmapTextureAtlas bitmapTextureAtlas = newBitmapTextureAtlas(64, 64,TextureOptions.BILINEAR_PREMULTIPLYALPHA);mBoxTextureRegion =BitmapTextureAtlasTextureRegionFactory.createFromAsset(bitmapTextureAtlas, this,"box_icon.png", 0, 0);mEngine.getTextureManager().loadTexture(bitmapTextureAtlas);}
  19. 19. Texture Atlas● Quite a pain for AndEngine ● Built by hand ● Size must be a power of 2 ● One big or many small ones?
  20. 20. Creating the Scene (1/3)public Scene onLoadScene() {Scene scene = new Scene();PhysicsWorld physicsWorld = new PhysicsWorld(newVector2(0, SensorManager.GRAVITY_EARTH), false);Shape ground = new Rectangle(0, camHeight - 2,camWidth, 2);FixtureDef wallFixtureDef =PhysicsFactory.createFixtureDef(0, 0.5f, 0.5f);PhysicsFactory.createBoxBody(physicsWorld, ground,BodyType.StaticBody, wallFixtureDef);scene.attachChild(ground);
  21. 21. Creating the Scene (2/3)Sprite box = new Sprite(0, 0, mBoxTextureRegion);FixtureDef boxFixture =PhysicsFactory.createFixtureDef(1, 0.5f, 0.5f);Body boxBody =PhysicsFactory.createBoxBody(physicsWorld, box,BodyType.DynamicBody, boxFixture);physicsWorld.registerPhysicsConnector(newPhysicsConnector(box, boxBody, true, true));scene.attachChild(box);
  22. 22. Creating the Scene (3/3)scene.registerUpdateHandler(physicsWorld);scene.registerUpdateHandler(mUpdateHandler);return scene;}
  23. 23. Types of bodies● Dynamic ● It is affected by physics like gravity● Kinematic ● It moves in a specified way● Static ● It does not move
  24. 24. More Interesting things● TiledTextures / Animated Sprites● Animations● Sound Engine● Particle Systems● Collision Detect● Polygonal Bodies● Menus
  25. 25. Intermission ← AndEngine Example apk
  26. 26. jPCT-AE
  27. 27. jPCT-AE● http://www.jpct.net/jpct-ae/● 3D Engine ● 3DObjects ● Lights ● etc● No physics ● It has collision detection
  28. 28. Games built with jPCT-AE● SpaceCat● SkyFrontier● Forgotten Elements● Mobialia Chess● Freddy Budgett● Alien Runner● ...
  29. 29. Games built with jPCT-AE
  30. 30. Project setupAdd jpct-ae.jar to libs / Build path
  31. 31. Concepts / Classes● Renderer / FrameBuffer● World● Texture / TextureManager● Object3D● Light● Camera
  32. 32. Game Architecture / jPCT-AE Game EngineDraw Thread Game Objects Update Thread Renderer World 3DObject
  33. 33. Preparing the GLSurfaceViewmGlView = (GLSurfaceView) findViewById(R.id.glview);mGlView.setKeepScreenOn(true);mViewRenderer = new MyRenderer(mGlView, mWorld);mGlView.setRenderer(mViewRenderer);
  34. 34. Renderer setuppublic void onDrawFrame(GL10 gl) { buffer.clear(back); synchronized (mWorld) { mWorld.renderScene(buffer); mWorld.draw(buffer); } buffer.display();}
  35. 35. Setup the WorldmWorld = new World();mWorld.setAmbientLight(150, 150, 150);
  36. 36. Loading TexturesResources res = getResources();Texture texture = new Texture(res.getDrawable(R.raw.texture));TextureManager.getInstance() .addTexture("texture", texture);
  37. 37. Loading ObjectsmModel = Loader.load3DS(getResources() .openRawResource(R.raw.model), 1)[0];mModel.setTexture("texture");mWorld.addObject(mModel);mWorld.buildAllObjects();
  38. 38. Creating LightsLight sun = new Light(mWorld);sun.setIntensity(250, 250, 250);SimpleVector sv = new SimpleVector(0, -100, -100);sun.setPosition(sv);
  39. 39. Handling the cameraCamera cam = mWorld.getCamera();cam.setPosition(new SimpleVector(0, 0,-100));cam.lookAt(mModel.getTransformedCenter());
  40. 40. More about the camera● It has a position ● Camera.setPosition● It has a target ● Camera.lookAt● It has a rotation ● Camera.setRotation
  41. 41. The 3D axis
  42. 42. Operations with objects● Hierarchy ● addChild● Move ● setPosition / translate● Rotation ● rotateX, rotateY, rotateZ
  43. 43. More Interesting Things● Keyframe Animations● Collision detect (Ellipsoids)● Billboards● Transparency● Culling● Primitive Objects
  44. 44. And a workaround● Overlay native layouts ● Menus ● Dialogs
  45. 45. Another Intermission ← jPCT-AE Example apk
  46. 46. Bonus: Other Engines● PlayN ● https://developers.google.com/playn/● NME ● http://www.haxenme.org/● Unity ● http://unity3d.com/● Game Maker ● http://www.yoyogames.com/make
  47. 47. Scores / Achievements
  48. 48. Why use a Library?● Not reinventing the wheel ● It is proven that works● Familiarity for users ● Other games use them● You do not own the servers ● You don’t, and that is good
  49. 49. Available libraries● ScoreLoop ● OpenFeint
  50. 50. What do you get?● Achievements ● Not very impressive● Leaderboards ● That is interesting● News Feed● Friends management● Improved engagement
  51. 51. Easy to integrate● Android Library Project● Initialize with the Application● Open a specific screen ● 2 lines of code● Submit a score or achievement ● 2 lines of code
  52. 52. MonetizationToo much to say for a single slide
  53. 53. And now...● Lunch● Pitch your game idea ● Gather a team● Hackaton● Demos, Pizza & Beer
  54. 54. Tools for Android GamesRaul Portales@sla_shalafi @thepilltreeraul@plattysoft.com http://thepilltree.com

×