diff --git a/core/assets/levels/level10.tmx b/core/assets/levels/level10.tmx new file mode 100644 index 0000000..f61c147 --- /dev/null +++ b/core/assets/levels/level10.tmx @@ -0,0 +1,22 @@ + + + + + + + + + + + eJxjYBgFo2B4ACYK9TMSqQaGKTWLFECJeUxYMDJghmJk9aS4B5t55AJK9A60HZSmv6EIAF6cACk= + + + + + + + + + + + diff --git a/core/assets/levels/level3.tmx b/core/assets/levels/level3.tmx new file mode 100644 index 0000000..f61c147 --- /dev/null +++ b/core/assets/levels/level3.tmx @@ -0,0 +1,22 @@ + + + + + + + + + + + eJxjYBgFo2B4ACYK9TMSqQaGKTWLFECJeUxYMDJghmJk9aS4B5t55AJK9A60HZSmv6EIAF6cACk= + + + + + + + + + + + diff --git a/core/assets/levels/level4.tmx b/core/assets/levels/level4.tmx new file mode 100644 index 0000000..f61c147 --- /dev/null +++ b/core/assets/levels/level4.tmx @@ -0,0 +1,22 @@ + + + + + + + + + + + eJxjYBgFo2B4ACYK9TMSqQaGKTWLFECJeUxYMDJghmJk9aS4B5t55AJK9A60HZSmv6EIAF6cACk= + + + + + + + + + + + diff --git a/core/assets/levels/level5.tmx b/core/assets/levels/level5.tmx new file mode 100644 index 0000000..2fb567c --- /dev/null +++ b/core/assets/levels/level5.tmx @@ -0,0 +1,22 @@ + + + + + + + + + + + eJztk8EKACAIQzX//5/rOEKWktGhHgxPy5kl8qmggSLokE31FprsH53xFYyIeRAVvofV+dmdNEcMdYS5mA/rLl6GarJ/OeLP3PVJsH/03bLsHTB3AJM= + + + + + + + + + + + diff --git a/core/assets/levels/level6.tmx b/core/assets/levels/level6.tmx new file mode 100644 index 0000000..f61c147 --- /dev/null +++ b/core/assets/levels/level6.tmx @@ -0,0 +1,22 @@ + + + + + + + + + + + eJxjYBgFo2B4ACYK9TMSqQaGKTWLFECJeUxYMDJghmJk9aS4B5t55AJK9A60HZSmv6EIAF6cACk= + + + + + + + + + + + diff --git a/core/assets/levels/level7.tmx b/core/assets/levels/level7.tmx new file mode 100644 index 0000000..f61c147 --- /dev/null +++ b/core/assets/levels/level7.tmx @@ -0,0 +1,22 @@ + + + + + + + + + + + eJxjYBgFo2B4ACYK9TMSqQaGKTWLFECJeUxYMDJghmJk9aS4B5t55AJK9A60HZSmv6EIAF6cACk= + + + + + + + + + + + diff --git a/core/assets/levels/level8.tmx b/core/assets/levels/level8.tmx new file mode 100644 index 0000000..f61c147 --- /dev/null +++ b/core/assets/levels/level8.tmx @@ -0,0 +1,22 @@ + + + + + + + + + + + eJxjYBgFo2B4ACYK9TMSqQaGKTWLFECJeUxYMDJghmJk9aS4B5t55AJK9A60HZSmv6EIAF6cACk= + + + + + + + + + + + diff --git a/core/assets/levels/level9.tmx b/core/assets/levels/level9.tmx new file mode 100644 index 0000000..f61c147 --- /dev/null +++ b/core/assets/levels/level9.tmx @@ -0,0 +1,22 @@ + + + + + + + + + + + eJxjYBgFo2B4ACYK9TMSqQaGKTWLFECJeUxYMDJghmJk9aS4B5t55AJK9A60HZSmv6EIAF6cACk= + + + + + + + + + + + diff --git a/core/assets/textures/levelSelectBackground.jpg b/core/assets/textures/levelSelectBackground.jpg new file mode 100644 index 0000000..2db44e8 Binary files /dev/null and b/core/assets/textures/levelSelectBackground.jpg differ diff --git a/core/src/com/game/Misc/CameraUtils.java b/core/src/com/game/Misc/CameraUtils.java index c6a97e9..83acf2e 100644 --- a/core/src/com/game/Misc/CameraUtils.java +++ b/core/src/com/game/Misc/CameraUtils.java @@ -9,15 +9,6 @@ import com.badlogic.gdx.math.Vector3; */ public class CameraUtils { - public static void lockOnTarget(Camera cam, float tarX, float tarY) - { - Vector3 pos = cam.position; - pos.x = tarX; - pos.y = tarY; - cam.position.set(pos); - cam.update(); - } - public static void lerpToTarget(Camera cam, float tarX, float tarY) { Vector3 pos = cam.position; diff --git a/core/src/com/game/Misc/levelSelectClickListener.java b/core/src/com/game/Misc/levelSelectClickListener.java new file mode 100644 index 0000000..b032ced --- /dev/null +++ b/core/src/com/game/Misc/levelSelectClickListener.java @@ -0,0 +1,24 @@ +package com.game.misc; + +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.game.App; + +/** + * Created by Ash on 13/02/2016. + */ +public class levelSelectClickListener extends ClickListener { + + private App app; + private int levelNumber; + + public levelSelectClickListener(App app, int levelNumber) + { + this.app = app; + this.levelNumber = levelNumber; + } + + @Override + public void clicked (com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) { + app.sm.setPlayScreen(levelNumber); + } +} diff --git a/core/src/com/game/Screens/Leaderboard.java b/core/src/com/game/Screens/Leaderboard.java index cfcd018..83fe2d5 100644 --- a/core/src/com/game/Screens/Leaderboard.java +++ b/core/src/com/game/Screens/Leaderboard.java @@ -5,7 +5,9 @@ import com.badlogic.gdx.Input; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.game.App; import com.game.managers.ScreenManager; @@ -14,22 +16,33 @@ import com.game.managers.ScreenManager; */ public class Leaderboard extends AbstractScreen { - private TextButton butBack; + private Skin skin; + + // Buttons private Vector2 buttonSize; + private TextButton butBack; public Leaderboard(App app) { super(app); + + skin = new Skin(); + buttonSize = new Vector2(50, 50); } @Override public void show() { super.show(); + + skin.add("default-font", app.assets.get("badaboom45.ttf", BitmapFont.class)); + skin.load(Gdx.files.internal("spritesheets/uiskin.json")); + + initButtons(); } @Override public void update(float dt) { - + stage.act(dt); } @Override @@ -38,8 +51,9 @@ public class Leaderboard extends AbstractScreen { app.sb.begin(); app.sb.draw(app.assets.get("textures/leaderboardBackground.jpg", Texture.class), 0, 0); - app.assets.get("badaboom25.ttf", BitmapFont.class).draw(app.sb,"Press M to go back to menu", 100, 100); app.sb.end(); + + stage.draw(); } @Override @@ -51,4 +65,19 @@ public class Leaderboard extends AbstractScreen { public void dispose() { super.dispose(); } + + private void initButtons() + { + butBack = new TextButton("Back", skin, "default"); + butBack.setPosition(buttonSize.x, buttonSize.y / 2); + butBack.setSize(buttonSize.x, buttonSize.y); + butBack.addListener(new ClickListener() { + @Override + public void clicked (com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) { + app.sm.setScreen(ScreenManager.Screen.MENU); + } + }); + + stage.addActor(butBack); + } } diff --git a/core/src/com/game/Screens/LevelSelect.java b/core/src/com/game/Screens/LevelSelect.java index af6d9ff..e6490e3 100644 --- a/core/src/com/game/Screens/LevelSelect.java +++ b/core/src/com/game/Screens/LevelSelect.java @@ -1,7 +1,105 @@ package com.game.screens; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.scenes.scene2d.ui.TextButton; +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.game.App; +import com.game.managers.ScreenManager; +import com.game.misc.levelSelectClickListener; + +import java.util.ArrayList; + /** * Created by Ash on 11/02/2016. */ -public class LevelSelect { +public class LevelSelect extends AbstractScreen { + + private Skin skin; + + // Buttons + private ArrayList butLevels = new ArrayList(); + private TextButton butEndless, butBack; + private Vector2 buttonSize; + + public LevelSelect(App app) { + super(app); + + skin = new Skin(); + buttonSize = new Vector2(50, 50); + } + + @Override + public void show() + { + super.show(); + + skin.add("default-font", app.assets.get("badaboom60.ttf", BitmapFont.class)); + skin.load(Gdx.files.internal("spritesheets/uiskin.json")); + + initButtons(); + } + + @Override + public void update(float dt) { + stage.act(dt); + } + + @Override + public void render(float dt) { + super.render(dt); + + app.sb.begin(); + app.sb.draw(app.assets.get("textures/levelSelectBackground.jpg", Texture.class), 0, 0); + app.sb.end(); + + stage.draw(); + } + + @Override + public void handleInput() { + if(Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE)) { app.sm.setScreen(ScreenManager.Screen.MENU); } + } + + @Override + public void dispose() + { + super.dispose(); + } + + private void initButtons() + { + butBack = new TextButton("Back", skin, "default"); + butBack.setPosition(buttonSize.x, buttonSize.y / 2); + butBack.setSize(buttonSize.x, buttonSize.y); + butBack.addListener(new ClickListener() { + @Override + public void clicked (com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) { + app.sm.setScreen(ScreenManager.Screen.MENU); + } + }); + + int tempCounter = 1; + for(int row = 0; row < 2; row++) + { + for(int col = 0; col < 5; col++) + { + TextButton butTemp = new TextButton(String.valueOf(tempCounter), skin, "default"); + butTemp.setPosition(500 + col * 60, 400 - row * 60); + butTemp.setSize(buttonSize.x, buttonSize.y); + butTemp.addListener(new levelSelectClickListener(app, tempCounter)); + + tempCounter++; + + stage.addActor(butTemp); + butLevels.add(butTemp); + } + } + + stage.addActor(butBack); + } } diff --git a/core/src/com/game/Screens/Loading.java b/core/src/com/game/Screens/Loading.java index 6aff0e2..1395ec2 100644 --- a/core/src/com/game/Screens/Loading.java +++ b/core/src/com/game/Screens/Loading.java @@ -99,6 +99,7 @@ public class Loading extends AbstractScreen { app.assets.load("textures/badlogic.jpg", Texture.class); app.assets.load("textures/menuBackground.jpg", Texture.class); app.assets.load("textures/leaderboardBackground.jpg", Texture.class); + app.assets.load("textures/levelSelectBackground.jpg", Texture.class); app.assets.load("textures/position0.png", Texture.class); app.assets.load("textures/position1.png", Texture.class); app.assets.load("textures/position2.png", Texture.class); diff --git a/core/src/com/game/Screens/Menu.java b/core/src/com/game/Screens/Menu.java index 5d15c3b..de21a0c 100644 --- a/core/src/com/game/Screens/Menu.java +++ b/core/src/com/game/Screens/Menu.java @@ -33,7 +33,7 @@ public class Menu extends AbstractScreen { super(app); skin = new Skin(); - buttonSize = new Vector2(128, 40); + buttonSize = new Vector2(50, 50); } @Override @@ -81,18 +81,17 @@ public class Menu extends AbstractScreen { private void initButtons() { butPlay = new TextButton("Play", skin, "default"); - butPlay.setPosition((stage.getWidth() / 2) - buttonSize.x / 2, buttonSize.y + 180); + butPlay.setPosition((stage.getWidth() / 2) - buttonSize.x / 2, buttonSize.y + 160); butPlay.setSize(buttonSize.x, buttonSize.y); butPlay.addListener(new ClickListener() { @Override public void clicked (com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) { - music.stop(); - app.sm.setPlayScreen(1); + app.sm.setScreen(ScreenManager.Screen.LEVELSELECT); } }); butLeaderboard = new TextButton("Leaderboard", skin, "default"); - butLeaderboard.setPosition((stage.getWidth() / 2) - buttonSize.x / 2, buttonSize.y + 100); + butLeaderboard.setPosition((stage.getWidth() / 2) - buttonSize.x / 2, buttonSize.y + 80); butLeaderboard.setSize(buttonSize.x, buttonSize.y); butLeaderboard.addListener(new ClickListener() { @Override @@ -102,7 +101,7 @@ public class Menu extends AbstractScreen { }); butExit = new TextButton("Exit", skin, "default"); - butExit.setPosition((stage.getWidth() / 2) - buttonSize.x / 2, buttonSize.y + 20); + butExit.setPosition((stage.getWidth() / 2) - buttonSize.x / 2, buttonSize.y); butExit.setSize(buttonSize.x, buttonSize.y); butExit.addListener(new ClickListener() { @Override @@ -111,9 +110,9 @@ public class Menu extends AbstractScreen { } }); - butPlay.addAction(sequence(alpha(0f), fadeIn(1f, Interpolation.pow2))); - butLeaderboard.addAction(sequence(alpha(0f), fadeIn(1.5f, Interpolation.pow2))); - butExit.addAction(sequence(alpha(0f), fadeIn(2f, Interpolation.pow2))); + //butPlay.addAction(sequence(alpha(0f), fadeIn(1f, Interpolation.pow2))); + //butLeaderboard.addAction(sequence(alpha(0f), fadeIn(1.5f, Interpolation.pow2))); + //butExit.addAction(sequence(alpha(0f), fadeIn(2f, Interpolation.pow2))); stage.addActor(butPlay); stage.addActor(butLeaderboard); diff --git a/core/src/com/game/Screens/Play.java b/core/src/com/game/Screens/Play.java index bd0f408..b7e70a0 100644 --- a/core/src/com/game/Screens/Play.java +++ b/core/src/com/game/Screens/Play.java @@ -5,6 +5,7 @@ import com.badlogic.gdx.Input; import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.OrthographicCamera; +import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.maps.MapLayer; import com.badlogic.gdx.maps.MapProperties; @@ -84,7 +85,7 @@ public class Play extends AbstractScreen { world.step(dt, 6, 2); CameraUtils.lerpToTarget(cam, player.getPos().scl(PPM).x, 0); - CameraUtils.lockOnTarget(b2dCam, player.getPos().x, player.getPos().y); + CameraUtils.lerpToTarget(b2dCam, player.getPos().x, player.getPos().y); Vector2 start = new Vector2(cam.viewportWidth / 2, cam.viewportHeight / 2); CameraUtils.setBoundary(cam, start, new Vector2(mapWidth * tileSize.x - start.x * 2, mapHeight * tileSize.y - start.y * 2)); @@ -101,7 +102,9 @@ public class Play extends AbstractScreen { if(!isDebug) { app.sb.begin(); - app.assets.get("badaboom25.ttf", BitmapFont.class).draw(app.sb,"Press M to go back to menu", 0, 0); + app.sb.draw(app.assets.get("textures/position0.png", Texture.class), cam.position.x - cam.viewportWidth / 2, cam.position.y - cam.viewportHeight / 2); + app.sb.draw(app.assets.get("textures/position1.png", Texture.class), cam.position.x - cam.viewportWidth / 2, cam.position.y - (cam.viewportHeight / 2) + 75); + app.sb.draw(app.assets.get("textures/position2.png", Texture.class), cam.position.x - cam.viewportWidth / 2, cam.position.y - (cam.viewportHeight / 2) - 150); player.render(app.sb); app.sb.end(); diff --git a/core/src/com/game/managers/ScreenManager.java b/core/src/com/game/managers/ScreenManager.java index 6e8d004..967a7e4 100644 --- a/core/src/com/game/managers/ScreenManager.java +++ b/core/src/com/game/managers/ScreenManager.java @@ -33,6 +33,7 @@ public class ScreenManager { screens.put(Screen.LOADING, new Loading(app)); screens.put(Screen.MENU, new Menu(app)); screens.put(Screen.LEADERBOARD, new Leaderboard(app)); + screens.put(Screen.LEVELSELECT, new LevelSelect(app)); } public void setPlayScreen(int levelNumber)