ITT 2014 - Mario Zechner - Libgdx 101

34
libGDX bootcamp

Transcript of ITT 2014 - Mario Zechner - Libgdx 101

Page 1: ITT 2014 - Mario Zechner - Libgdx 101

libGDX bootcamp

Page 2: ITT 2014 - Mario Zechner - Libgdx 101

What is libGDX?

• Cross-platform game development framework • Java + C/C++ for performance hungry code • Use Java, Scala, Kotlin, ... • Write once ...

http://libgdx.badlogicgames.com http://github.com/libgdx/libgdx

@badlogicgames, @libgdx

Page 3: ITT 2014 - Mario Zechner - Libgdx 101

Deploy to

Page 4: ITT 2014 - Mario Zechner - Libgdx 101

Develop with

Page 5: ITT 2014 - Mario Zechner - Libgdx 101

Who‘s using it?

Page 6: ITT 2014 - Mario Zechner - Libgdx 101

Who‘s using it?

Page 7: ITT 2014 - Mario Zechner - Libgdx 101

Features

Page 8: ITT 2014 - Mario Zechner - Libgdx 101

Features

Low-Level

Mid-Level

High-Level

Page 9: ITT 2014 - Mario Zechner - Libgdx 101

Features

Low-Level

Mid-Level

High-Level Application Management File I/O Networking Audio Graphics (OpenGL ES 2.0/3.0) Input

Page 10: ITT 2014 - Mario Zechner - Libgdx 101

Features

Low-Level

Mid-Level

High-Level Meshes, Shaders, Textures, ... Sprite & Polygon Batching Texture Atlas, Bitmap Font Asset Manager Math Library Custom Collections JSON/XML (de-)serialization

Page 11: ITT 2014 - Mario Zechner - Libgdx 101

Features

Low-Level

Mid-Level

High-Level

Box2D & Bullet Physics Map Loading 2D Scene Graph + UI Toolkit 3D API

Page 12: ITT 2014 - Mario Zechner - Libgdx 101

It‘s a framework, not an engine Mix & Match, use and combine features from any level

Page 14: ITT 2014 - Mario Zechner - Libgdx 101

Lets write a game

Actually, we‘ll just quickly prototyp a game

A real game needs more code and assets

Page 15: ITT 2014 - Mario Zechner - Libgdx 101

The plane that couldn‘t fly good

Thanks Kenney! http://kenney.nl/

Page 16: ITT 2014 - Mario Zechner - Libgdx 101

Assets

Plane, 3 frames, 88x73px

Ground, 808x71px

Rock, up & down, 108x239px Background, 800x480

music.mp3

explode.wav

arial.fnt, arial.png

Page 17: ITT 2014 - Mario Zechner - Libgdx 101

Live-Coding Session https://github.com/badlogic/theplanethatcould

ntflygood

Page 18: ITT 2014 - Mario Zechner - Libgdx 101

Thanks!

Page 19: ITT 2014 - Mario Zechner - Libgdx 101

Low-Level Layer

Application Management • Lifecycle events • Window management • Rendering loop • Threading Gdx.app, ApplicationListener, LwjglApplication, AndroidApplication, IOSApplication, GwtApplication ,...

Page 20: ITT 2014 - Mario Zechner - Libgdx 101

Low-Level Layer

File I/O

• Unified across platforms

• Preferences (persistent map)

• Sane file manipulation API

Gdx.files, FileHandle, ...

Page 21: ITT 2014 - Mario Zechner - Libgdx 101

Low-Level Layer

Networking

• Open URL in browser

• HTTP, HTTPs API ala HttpClient

• Socket API

Gdx.net, HttpRequest, HttpResponse, Socket,

ServerSocket, ...

Page 22: ITT 2014 - Mario Zechner - Libgdx 101

Low-Level Layer

Audio

• Streaming playback for music

• In-memory playback for sound effects

• PCM read/write

• Panning, volume, pitch

Gdx.audio, Sound, Music, AudioDevice, ...

Page 23: ITT 2014 - Mario Zechner - Libgdx 101

Low-Level Layer

Graphics

• OpenGL ES 2.0, 3.0

• Display mode API

• Continuous & non-continuous rendering

• Custom 2D Bitmap manipulation API

Gdx.graphics, GL20, GL30, Pixmap, PixmapIO, ...

Page 24: ITT 2014 - Mario Zechner - Libgdx 101

Low-Level Layer

Input

• Keyboard, Mouse, Touch

• Accelerometer, Compass, Vibrator

• On-screen Keyboard

Gdx.input, InputProcessor, ...

Page 25: ITT 2014 - Mario Zechner - Libgdx 101

Mid-Level Layer

Graphic Utilities • Shaders, textures, meshes, framebuffer objects • Polygon & spritebatch, texture regions, texture

atlas, bitmap fonts, 2D particle system, shape renderer

ShaderProgram, Texture, TextureRegion, Mesh, Framebuffer, PolygonBatch, SpriteBatch, TextureAtlas, BitmapFont, ...

Page 26: ITT 2014 - Mario Zechner - Libgdx 101

Mid-Level Layer

Input

• Input Multiplexing

• Gesture Detector

InputMultiplexer, GestureDetector

Page 27: ITT 2014 - Mario Zechner - Libgdx 101

Mid-Level Layer

Math • Matrices, vectors, quaternions • Bounding shapes, Intersection testing • Cameras • Splines • Triangulation Matrix4, Matrix3, Vector2, Vector3, Quaternion, BoundingBox, Rectangle, Circle, OrthographicCamera, PerspectiveCamera, CatmullRomSpline, DelaunayTriangulator, ...

Page 28: ITT 2014 - Mario Zechner - Libgdx 101

Mid-Level Layer

Asset Manager

• Threaded

• Asynchronous loading

• Reference counting

• Pluggable API

AssetManager, ...

Page 29: ITT 2014 - Mario Zechner - Libgdx 101

Mid-Level Layer

Custom Collections & Serialization

• Lists, maps, sets, pools

• Garbage Collector aware

• JSON POJO (de-)serialization

• XML parsing/writting

Array, ObjectMap, Pool, Json, XmlReader, ...

Page 30: ITT 2014 - Mario Zechner - Libgdx 101

High-Level Layer

Physics

• Box2D JNI wrapper

• Bullet JNI wrapper

Page 31: ITT 2014 - Mario Zechner - Libgdx 101

High-Level Layer

Map Loading

• Orthographic & isometric tile maps

• Generic API

Page 32: ITT 2014 - Mario Zechner - Libgdx 101

High-Level Layer

2D Scene Graph

• Tweening

• Skinable UI toolkit

• Table-based layouting

• Viewport management

Stage, Skin, Button, Table, ...

Page 33: ITT 2014 - Mario Zechner - Libgdx 101

High-Level Layer

3D API (WIP!) • FBX, DAE, OBJ support • GPU Skinning • Material system • Shadow Mapping, Cube Mapping, ... • Extremely flexible Batching API ModelBatch, ModelInstance, Material, Environment, Renderable, RenderableProvider, Shader, ...

Page 34: ITT 2014 - Mario Zechner - Libgdx 101

Extensions

• Not part of the core API

• gdx-freetype (desktop, Android, iOS)

• gdx-bullet (desktop, Android, iOS)

• gdx-box2d (desktop, Android, iOS, HTML)

• gdx-controllers (desktop, Android, iOS, HTML)