symphony flow - cross-platform game development

23
Symphony is a culture-driven technology house. Zarko Oroz

Upload: symphony

Post on 19-Feb-2017

55 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Symphony flow - Cross-platform Game Development

Symphony is a culture-driven technology house.

Zarko Oroz

Page 2: Symphony flow - Cross-platform Game Development

Cross-Platform Game DevelopmentBunny Hopper

Page 3: Symphony flow - Cross-platform Game Development

Bunny Hopper

2D Arcade gameRetro style

8bit textures and music

Developed in free time

Page 4: Symphony flow - Cross-platform Game Development

libGDX

Cross-platform game and visualization development framework

Open sourceWritten in the Java

programming language with some C and C++ components for performance

V1.0 released in 2014 current is 1.9

Page 5: Symphony flow - Cross-platform Game Development

libGDX

Page 6: Symphony flow - Cross-platform Game Development

libGDX

Page 7: Symphony flow - Cross-platform Game Development

libGDX

Page 8: Symphony flow - Cross-platform Game Development

Before we beginFree Textures:http://opengameart.org/

Free Sounds:http://www.littlerobotsoundfactory.com/

Assets

Textures

Sounds

Page 9: Symphony flow - Cross-platform Game Development

Let’s Start (libGDX Android)

Download & Rungdx-setup.jar file

GUI project generator

ProjectsAndroid

Core1 2 3

Fill info, select platforms and extensions

Page 10: Symphony flow - Cross-platform Game Development

libGDXGUI project generator

Page 11: Symphony flow - Cross-platform Game Development

libGDXAndroidCore

Application Adaptercreate()render()

Page 12: Symphony flow - Cross-platform Game Development

BunnyHopperBackground2 TexturesBackground velocityTrack BackgroundY

Move background to top

...Texture[] backgrounds;float backgroundVelocity = 10f;int backgroundSize = 2;float[] backgroundY = new float[backgroundSize];...

public void create() {...backgrounds = new Texture[backgroundSize];backgrounds[0] = new Texture("grass_4.jpg");backgrounds[1] = new Texture("grass_4.jpg");backgroundY[0] = 0;backgroundY[1] = Gdx.graphics.getHeight();...

public void render() {…for (int i = 0; i < backgroundSize; i++) { if (backgroundY[i] < -Gdx.graphics.getHeight()) { backgroundY[i] = backgroundY[i == 0 ? 1 : 0] + Gdx.graphics.getHeight(); Gdx.app.log("Move", "true"); } else { backgroundY[i] = backgroundY[i] - backgroundVelocity; } batch.draw(backgrounds[0], 0, backgroundY[0], Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); batch.draw(backgrounds[1], 0, backgroundY[1], Gdx.graphics.getWidth(), Gdx.graphics.getHeight());}...

Page 13: Symphony flow - Cross-platform Game Development

BunnyHopper Background Video

Page 14: Symphony flow - Cross-platform Game Development

...Texture[] run;Texture[] jump;TextureRegion[] runFrames;TextureRegion[] jumpFrames;Animation runAnimation;Animation jumpAnimation;

TextureRegion currentFrame;float slateTime;float bunnyY = 0;float startBunnyY = 0;float velocity = 0;float gravity = 1f;...

public void create() {...startBunnyY = Gdx.graphics.getHeight() / 10;bunnyY = startBunnyY;runFrames = new TextureRegion[2];jumpFrames = new TextureRegion[8];

run = new Texture[2];run[0] = new Texture(Gdx.files.internal("run1.png"));run[1] = new Texture(Gdx.files.internal("run2.png"));runFrames[0] = new TextureRegion(run[0]);runFrames[1] = new TextureRegion(run[1]);

runAnimation = new Animation(0.125f, runFrames);slateTime = 0f;...

Running animationJumping animationDefault state

BunnyHopperMain Character

Page 15: Symphony flow - Cross-platform Game Development

public void render() {…slateTime += Gdx.graphics.getDeltaTime();if (bunnyY > startBunnyY || velocity < 0) { velocity = velocity + gravity; bunnyY -= velocity; }if ((/*Gdx.input.justTouched() ||*/ Gdx.input.getAccelerometerZ() > 15) && bunnyY <= startBunnyY) { // Jump velocity = -25;}if (bunnyY > startBunnyY) { currentFrame = jumpAnimation.getKeyFrame(slateTime, true);} else { currentFrame = runAnimation.getKeyFrame(slateTime, true);}//draw bunnybatch.draw(currentFrame, Gdx.graphics.getWidth() / 2 - BUNNY_SIZE / 2, bunnyY, BUNNY_SIZE, BUNNY_SIZE);...

Running animationJumping animationDefault state

BunnyHopperMain Character

Page 16: Symphony flow - Cross-platform Game Development

BunnyHopper Main Character Video

Page 17: Symphony flow - Cross-platform Game Development

Texture[] obstacles;int numberOfObstacles = 4;int minGap = 600;int maxGap = 1200;int obstacleHeight = 135;int lastObstacleY = 0;int scoringObstacle = 0;…public void create() {…obstacles = new Texture[numberOfObstacles];setObstacles();

obstacles[0] = new Texture("wall.png");obstacles[1] = new Texture("fence.png");obstacles[2] = new Texture("stone.png");obstacles[3] = new Texture("ground.png");lastObstacleY = Gdx.graphics.getHeight() + obstacleHeight;…public void render() {...for (int i = 0; i < numberOfObstacles; i++) { obstaclesRectangles[i].y = obstaclesRectangles[i].y - backgroundVelocity; batch.draw(obstacles[i], 0, obstaclesRectangles[i].y, obstaclesRectangles[i].width, obstaclesRectangles[i].height);

if (obstaclesRectangles[i].y > lastObstacleY) lastObstacleY = (int) obstaclesRectangles[i].y;

if (obstaclesRectangles[i].y < -Gdx.graphics.getHeight()) { Gdx.app.log("Move Obstacle", "true"); obstaclesRectangles[i].y = Gdx.graphics.getHeight() + obstacleHeight + getGap(); }

4 obstaclesRandom gapMove to top when

exits screenTrack scoring

obstacle

BunnyHopperObstacles

Page 18: Symphony flow - Cross-platform Game Development

BunnyHopper Obstacles Video

Page 19: Symphony flow - Cross-platform Game Development

Jump over obstacleDetect collision

shapesTrack bunnyY and

animationScore saved in

Preferences

ShapeRenderer shapeRenderer;Rectangle bunnyRect;Rectangle[] obstaclesRectangles;int score = 0;int scoringObstacle = 0;boolean newRecord;…public void create() {…shapeRenderer = new ShapeRenderer();bunnyRect = new Rectangle();obstaclesRectangles = new Rectangle[numberOfObstacles];…public void render() {…bunnyRect.set(Gdx.graphics.getWidth() / 2 - BUNNY_SIZE / 2, bunnyY, BUNNY_SIZE, BUNNY_SIZE);for (int i = 0; i < numberOfObstacles; i++) { obstaclesRectangles[i].y = obstaclesRectangles[i].y - backgroundVelocity;if (bunnyY <= startBunnyY && Intersector.overlaps(bunnyRect, obstaclesRectangles[i])) { Gdx.app.log("DEAD", "true"); // update high score if (score > getHighScore()) { newRecord = true; setHighScore(score); }}if (obstaclesRectangles[scoringObstacle].y < Gdx.graphics.getHeight() && obstaclesRectangles[scoringObstacle].y - obstaclesRectangles[scoringObstacle].getHeight() < startBunnyY - BUNNY_SIZE) { score++; Gdx.app.log("Score", String.valueOf(score)); if (scoringObstacle < numberOfObstacles - 1) { scoringObstacle++; } else { scoringObstacle = 0; }}

BunnyHopperCollision and Scoring

Page 20: Symphony flow - Cross-platform Game Development

BunnyHopper Collision and scoring video

Page 21: Symphony flow - Cross-platform Game Development

Background musicSounds

Start soundJump soundDead soundHighScore sound

Music themeSound;Sound jumpSound, deadSound, startSound, newRecordSound;…public void create() {…jumpSound = Gdx.audio.newSound(Gdx.files.internal("jumpland.wav"));deadSound = Gdx.audio.newSound(Gdx.files.internal("dead.ogg"));startSound = Gdx.audio.newSound(Gdx.files.internal("start.wav"));newRecordSound = Gdx.audio.newSound(Gdx.files.internal("new_record.mp3"));themeSound = Gdx.audio.newMusic(Gdx.files.internal("theme_song_2.ogg"));themeSound.setLooping(true);themeSound.setVolume(0.4f);themeSound.play();…public void render() {…if ((/*Gdx.input.justTouched() ||*/ Gdx.input.getAccelerometerZ() > 15) && bunnyY <= startBunnyY) { jumpSound.play();…

BunnyHopperSounds and Music

Page 22: Symphony flow - Cross-platform Game Development

ReadyBest scoreInstructions

RunningRender

GameOverScoreTap to restart

BunnyHopperGame States

Page 23: Symphony flow - Cross-platform Game Development

BunnyHopper Final game video