Level select menu

This commit is contained in:
Ash Reynolds 2016-02-13 01:12:43 +00:00
parent cfb59a3c4a
commit 4593a6c686
17 changed files with 346 additions and 24 deletions

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="50" height="8" tilewidth="64" tileheight="64" nextobjectid="25">
<tileset firstgid="1" name="platformSet" tilewidth="64" tileheight="64" tilecount="3" columns="3">
<image source="../spritesheets/platformSet.png" width="192" height="64"/>
</tileset>
<tileset firstgid="4" name="player" tilewidth="64" tileheight="64" tilecount="1" columns="1">
<image source="../textures/player.png" width="64" height="64"/>
</tileset>
<layer name="PLATFORM" width="50" height="8">
<data encoding="base64" compression="zlib">
eJxjYBgFo2B4ACYK9TMSqQaGKTWLFECJeUxYMDJghmJk9aS4B5t55AJK9A60HZSmv6EIAF6cACk=
</data>
</layer>
<objectgroup name="PLAYER">
<object id="22" gid="4" x="0" y="256" width="64" height="64"/>
</objectgroup>
<objectgroup name="BOUNDARY">
<object id="21" x="0" y="-277.333">
<polyline points="0,85.3333 0,1109.33 3328,1109.33 3328,85.3333 0,85.3333"/>
</object>
</objectgroup>
</map>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="50" height="8" tilewidth="64" tileheight="64" nextobjectid="25">
<tileset firstgid="1" name="platformSet" tilewidth="64" tileheight="64" tilecount="3" columns="3">
<image source="../spritesheets/platformSet.png" width="192" height="64"/>
</tileset>
<tileset firstgid="4" name="player" tilewidth="64" tileheight="64" tilecount="1" columns="1">
<image source="../textures/player.png" width="64" height="64"/>
</tileset>
<layer name="PLATFORM" width="50" height="8">
<data encoding="base64" compression="zlib">
eJxjYBgFo2B4ACYK9TMSqQaGKTWLFECJeUxYMDJghmJk9aS4B5t55AJK9A60HZSmv6EIAF6cACk=
</data>
</layer>
<objectgroup name="PLAYER">
<object id="22" gid="4" x="0" y="256" width="64" height="64"/>
</objectgroup>
<objectgroup name="BOUNDARY">
<object id="21" x="0" y="-277.333">
<polyline points="0,85.3333 0,1109.33 3328,1109.33 3328,85.3333 0,85.3333"/>
</object>
</objectgroup>
</map>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="50" height="8" tilewidth="64" tileheight="64" nextobjectid="25">
<tileset firstgid="1" name="platformSet" tilewidth="64" tileheight="64" tilecount="3" columns="3">
<image source="../spritesheets/platformSet.png" width="192" height="64"/>
</tileset>
<tileset firstgid="4" name="player" tilewidth="64" tileheight="64" tilecount="1" columns="1">
<image source="../textures/player.png" width="64" height="64"/>
</tileset>
<layer name="PLATFORM" width="50" height="8">
<data encoding="base64" compression="zlib">
eJxjYBgFo2B4ACYK9TMSqQaGKTWLFECJeUxYMDJghmJk9aS4B5t55AJK9A60HZSmv6EIAF6cACk=
</data>
</layer>
<objectgroup name="PLAYER">
<object id="22" gid="4" x="0" y="256" width="64" height="64"/>
</objectgroup>
<objectgroup name="BOUNDARY">
<object id="21" x="0" y="-277.333">
<polyline points="0,85.3333 0,1109.33 3328,1109.33 3328,85.3333 0,85.3333"/>
</object>
</objectgroup>
</map>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="50" height="8" tilewidth="64" tileheight="64" nextobjectid="25">
<tileset firstgid="1" name="platformSet" tilewidth="64" tileheight="64" tilecount="3" columns="3">
<image source="../spritesheets/platformSet.png" width="192" height="64"/>
</tileset>
<tileset firstgid="4" name="player" tilewidth="64" tileheight="64" tilecount="1" columns="1">
<image source="../textures/player.png" width="64" height="64"/>
</tileset>
<layer name="PLATFORM" width="50" height="8">
<data encoding="base64" compression="zlib">
eJztk8EKACAIQzX//5/rOEKWktGhHgxPy5kl8qmggSLokE31FprsH53xFYyIeRAVvofV+dmdNEcMdYS5mA/rLl6GarJ/OeLP3PVJsH/03bLsHTB3AJM=
</data>
</layer>
<objectgroup name="PLAYER">
<object id="24" gid="4" x="0" y="320" width="64" height="64"/>
</objectgroup>
<objectgroup name="BOUNDARY">
<object id="23" x="0" y="-192">
<polyline points="0,0 0,1024 3328,1024 3328,0 0,0"/>
</object>
</objectgroup>
</map>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="50" height="8" tilewidth="64" tileheight="64" nextobjectid="25">
<tileset firstgid="1" name="platformSet" tilewidth="64" tileheight="64" tilecount="3" columns="3">
<image source="../spritesheets/platformSet.png" width="192" height="64"/>
</tileset>
<tileset firstgid="4" name="player" tilewidth="64" tileheight="64" tilecount="1" columns="1">
<image source="../textures/player.png" width="64" height="64"/>
</tileset>
<layer name="PLATFORM" width="50" height="8">
<data encoding="base64" compression="zlib">
eJxjYBgFo2B4ACYK9TMSqQaGKTWLFECJeUxYMDJghmJk9aS4B5t55AJK9A60HZSmv6EIAF6cACk=
</data>
</layer>
<objectgroup name="PLAYER">
<object id="22" gid="4" x="0" y="256" width="64" height="64"/>
</objectgroup>
<objectgroup name="BOUNDARY">
<object id="21" x="0" y="-277.333">
<polyline points="0,85.3333 0,1109.33 3328,1109.33 3328,85.3333 0,85.3333"/>
</object>
</objectgroup>
</map>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="50" height="8" tilewidth="64" tileheight="64" nextobjectid="25">
<tileset firstgid="1" name="platformSet" tilewidth="64" tileheight="64" tilecount="3" columns="3">
<image source="../spritesheets/platformSet.png" width="192" height="64"/>
</tileset>
<tileset firstgid="4" name="player" tilewidth="64" tileheight="64" tilecount="1" columns="1">
<image source="../textures/player.png" width="64" height="64"/>
</tileset>
<layer name="PLATFORM" width="50" height="8">
<data encoding="base64" compression="zlib">
eJxjYBgFo2B4ACYK9TMSqQaGKTWLFECJeUxYMDJghmJk9aS4B5t55AJK9A60HZSmv6EIAF6cACk=
</data>
</layer>
<objectgroup name="PLAYER">
<object id="22" gid="4" x="0" y="256" width="64" height="64"/>
</objectgroup>
<objectgroup name="BOUNDARY">
<object id="21" x="0" y="-277.333">
<polyline points="0,85.3333 0,1109.33 3328,1109.33 3328,85.3333 0,85.3333"/>
</object>
</objectgroup>
</map>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="50" height="8" tilewidth="64" tileheight="64" nextobjectid="25">
<tileset firstgid="1" name="platformSet" tilewidth="64" tileheight="64" tilecount="3" columns="3">
<image source="../spritesheets/platformSet.png" width="192" height="64"/>
</tileset>
<tileset firstgid="4" name="player" tilewidth="64" tileheight="64" tilecount="1" columns="1">
<image source="../textures/player.png" width="64" height="64"/>
</tileset>
<layer name="PLATFORM" width="50" height="8">
<data encoding="base64" compression="zlib">
eJxjYBgFo2B4ACYK9TMSqQaGKTWLFECJeUxYMDJghmJk9aS4B5t55AJK9A60HZSmv6EIAF6cACk=
</data>
</layer>
<objectgroup name="PLAYER">
<object id="22" gid="4" x="0" y="256" width="64" height="64"/>
</objectgroup>
<objectgroup name="BOUNDARY">
<object id="21" x="0" y="-277.333">
<polyline points="0,85.3333 0,1109.33 3328,1109.33 3328,85.3333 0,85.3333"/>
</object>
</objectgroup>
</map>

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="50" height="8" tilewidth="64" tileheight="64" nextobjectid="25">
<tileset firstgid="1" name="platformSet" tilewidth="64" tileheight="64" tilecount="3" columns="3">
<image source="../spritesheets/platformSet.png" width="192" height="64"/>
</tileset>
<tileset firstgid="4" name="player" tilewidth="64" tileheight="64" tilecount="1" columns="1">
<image source="../textures/player.png" width="64" height="64"/>
</tileset>
<layer name="PLATFORM" width="50" height="8">
<data encoding="base64" compression="zlib">
eJxjYBgFo2B4ACYK9TMSqQaGKTWLFECJeUxYMDJghmJk9aS4B5t55AJK9A60HZSmv6EIAF6cACk=
</data>
</layer>
<objectgroup name="PLAYER">
<object id="22" gid="4" x="0" y="256" width="64" height="64"/>
</objectgroup>
<objectgroup name="BOUNDARY">
<object id="21" x="0" y="-277.333">
<polyline points="0,85.3333 0,1109.33 3328,1109.33 3328,85.3333 0,85.3333"/>
</object>
</objectgroup>
</map>

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

View file

@ -9,15 +9,6 @@ import com.badlogic.gdx.math.Vector3;
*/ */
public class CameraUtils { 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) public static void lerpToTarget(Camera cam, float tarX, float tarY)
{ {
Vector3 pos = cam.position; Vector3 pos = cam.position;

View file

@ -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);
}
}

View file

@ -5,7 +5,9 @@ import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.math.Vector2; 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.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.game.App; import com.game.App;
import com.game.managers.ScreenManager; import com.game.managers.ScreenManager;
@ -14,22 +16,33 @@ import com.game.managers.ScreenManager;
*/ */
public class Leaderboard extends AbstractScreen { public class Leaderboard extends AbstractScreen {
private TextButton butBack; private Skin skin;
// Buttons
private Vector2 buttonSize; private Vector2 buttonSize;
private TextButton butBack;
public Leaderboard(App app) { public Leaderboard(App app) {
super(app); super(app);
skin = new Skin();
buttonSize = new Vector2(50, 50);
} }
@Override @Override
public void show() { public void show() {
super.show(); super.show();
skin.add("default-font", app.assets.get("badaboom45.ttf", BitmapFont.class));
skin.load(Gdx.files.internal("spritesheets/uiskin.json"));
initButtons();
} }
@Override @Override
public void update(float dt) { public void update(float dt) {
stage.act(dt);
} }
@Override @Override
@ -38,8 +51,9 @@ public class Leaderboard extends AbstractScreen {
app.sb.begin(); app.sb.begin();
app.sb.draw(app.assets.get("textures/leaderboardBackground.jpg", Texture.class), 0, 0); 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(); app.sb.end();
stage.draw();
} }
@Override @Override
@ -51,4 +65,19 @@ public class Leaderboard extends AbstractScreen {
public void dispose() { public void dispose() {
super.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);
}
} }

View file

@ -1,7 +1,105 @@
package com.game.screens; 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. * Created by Ash on 11/02/2016.
*/ */
public class LevelSelect { public class LevelSelect extends AbstractScreen {
private Skin skin;
// Buttons
private ArrayList<TextButton> butLevels = new ArrayList<TextButton>();
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);
}
} }

View file

@ -99,6 +99,7 @@ public class Loading extends AbstractScreen {
app.assets.load("textures/badlogic.jpg", Texture.class); app.assets.load("textures/badlogic.jpg", Texture.class);
app.assets.load("textures/menuBackground.jpg", Texture.class); app.assets.load("textures/menuBackground.jpg", Texture.class);
app.assets.load("textures/leaderboardBackground.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/position0.png", Texture.class);
app.assets.load("textures/position1.png", Texture.class); app.assets.load("textures/position1.png", Texture.class);
app.assets.load("textures/position2.png", Texture.class); app.assets.load("textures/position2.png", Texture.class);

View file

@ -33,7 +33,7 @@ public class Menu extends AbstractScreen {
super(app); super(app);
skin = new Skin(); skin = new Skin();
buttonSize = new Vector2(128, 40); buttonSize = new Vector2(50, 50);
} }
@Override @Override
@ -81,18 +81,17 @@ public class Menu extends AbstractScreen {
private void initButtons() private void initButtons()
{ {
butPlay = new TextButton("Play", skin, "default"); 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.setSize(buttonSize.x, buttonSize.y);
butPlay.addListener(new ClickListener() { butPlay.addListener(new ClickListener() {
@Override @Override
public void clicked (com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) { public void clicked (com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) {
music.stop(); app.sm.setScreen(ScreenManager.Screen.LEVELSELECT);
app.sm.setPlayScreen(1);
} }
}); });
butLeaderboard = new TextButton("Leaderboard", skin, "default"); 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.setSize(buttonSize.x, buttonSize.y);
butLeaderboard.addListener(new ClickListener() { butLeaderboard.addListener(new ClickListener() {
@Override @Override
@ -102,7 +101,7 @@ public class Menu extends AbstractScreen {
}); });
butExit = new TextButton("Exit", skin, "default"); 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.setSize(buttonSize.x, buttonSize.y);
butExit.addListener(new ClickListener() { butExit.addListener(new ClickListener() {
@Override @Override
@ -111,9 +110,9 @@ public class Menu extends AbstractScreen {
} }
}); });
butPlay.addAction(sequence(alpha(0f), fadeIn(1f, Interpolation.pow2))); //butPlay.addAction(sequence(alpha(0f), fadeIn(1f, Interpolation.pow2)));
butLeaderboard.addAction(sequence(alpha(0f), fadeIn(1.5f, Interpolation.pow2))); //butLeaderboard.addAction(sequence(alpha(0f), fadeIn(1.5f, Interpolation.pow2)));
butExit.addAction(sequence(alpha(0f), fadeIn(2f, Interpolation.pow2))); //butExit.addAction(sequence(alpha(0f), fadeIn(2f, Interpolation.pow2)));
stage.addActor(butPlay); stage.addActor(butPlay);
stage.addActor(butLeaderboard); stage.addActor(butLeaderboard);

View file

@ -5,6 +5,7 @@ import com.badlogic.gdx.Input;
import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.maps.MapLayer; import com.badlogic.gdx.maps.MapLayer;
import com.badlogic.gdx.maps.MapProperties; import com.badlogic.gdx.maps.MapProperties;
@ -84,7 +85,7 @@ public class Play extends AbstractScreen {
world.step(dt, 6, 2); world.step(dt, 6, 2);
CameraUtils.lerpToTarget(cam, player.getPos().scl(PPM).x, 0); 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); 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)); 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) if(!isDebug)
{ {
app.sb.begin(); 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); player.render(app.sb);
app.sb.end(); app.sb.end();

View file

@ -33,6 +33,7 @@ public class ScreenManager {
screens.put(Screen.LOADING, new Loading(app)); screens.put(Screen.LOADING, new Loading(app));
screens.put(Screen.MENU, new Menu(app)); screens.put(Screen.MENU, new Menu(app));
screens.put(Screen.LEADERBOARD, new Leaderboard(app)); screens.put(Screen.LEADERBOARD, new Leaderboard(app));
screens.put(Screen.LEVELSELECT, new LevelSelect(app));
} }
public void setPlayScreen(int levelNumber) public void setPlayScreen(int levelNumber)