From 61322d04d4eedfd5cc1d46234329baa083c0a570 Mon Sep 17 00:00:00 2001 From: Ash Reynolds Date: Tue, 16 Feb 2016 16:10:25 +0000 Subject: [PATCH] More UI changes --- core/src/com/game/Screens/Loading.java | 1 - core/src/com/game/Screens/Play.java | 49 ++++++++++++++------------ 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/core/src/com/game/Screens/Loading.java b/core/src/com/game/Screens/Loading.java index b35d1bb..c9ad50d 100644 --- a/core/src/com/game/Screens/Loading.java +++ b/core/src/com/game/Screens/Loading.java @@ -13,7 +13,6 @@ import com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.math.Interpolation; import com.badlogic.gdx.math.Rectangle; -import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.game.App; import com.game.managers.ScreenManager; diff --git a/core/src/com/game/Screens/Play.java b/core/src/com/game/Screens/Play.java index 40a1bca..22be5f2 100644 --- a/core/src/com/game/Screens/Play.java +++ b/core/src/com/game/Screens/Play.java @@ -85,8 +85,10 @@ public class Play extends AbstractScreen { private Image failureBackground, successBackground; // Progress bar - private float percent; private Rectangle progressRect; + private Texture progressTexture; + private float percent; + private float progressX; private int levelNumber; @@ -126,6 +128,7 @@ public class Play extends AbstractScreen { skin.load(Gdx.files.internal("spritesheets/uiskin.json")); progressRect = new Rectangle(stage.getWidth() - 550, (stage.getHeight() - 50), 0, 25); + progressTexture = app.assets.get("textures/player_red.png", Texture.class); initLevel(); initIntroWindow(); @@ -146,10 +149,8 @@ public class Play extends AbstractScreen { 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)); - percent = Interpolation.linear.apply(percent, 500, 0.3f ); - System.out.println(mapWidth - player.getPos().x); - progressRect.width = 0 + 500 * percent; - if (progressRect.width >= 499) { progressRect.width = 500; } + percent = Interpolation.linear.apply(percent, (player.getPos().x * PPM) / (mapWidth * tileSize.x), 0.2f ); + progressX = (progressRect.x + 500 * percent) - player.getSize().x / 2; player.update(dt); } @@ -179,9 +180,9 @@ public class Play extends AbstractScreen { if(!isDebug) { app.sb.begin(); - 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); + 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) * .1f, cam.position.y - (cam.viewportHeight / 2) + 75); + app.sb.draw(app.assets.get("textures/position2.png", Texture.class), (cam.position.x - cam.viewportWidth / 2) * .01f, cam.position.y - (cam.viewportHeight / 2) - 150); player.render(app.sb); app.sb.end(); @@ -199,7 +200,8 @@ public class Play extends AbstractScreen { app.sr.end(); app.sb.begin(); - app.sb.draw(app.assets.get("spritesheets/platformSet.png", Texture.class), 100, 100); + app.sb.draw(app.assets.get("spritesheets/platformSet.png", Texture.class), 100, (stage.getHeight() - 50)); + app.sb.draw(progressTexture, progressX, progressRect.y, 30, 30); app.sb.end(); } else @@ -224,33 +226,34 @@ public class Play extends AbstractScreen { System.out.println("isPaused: " + isPaused); } - if(Gdx.input.isKeyJustPressed(Input.Keys.NUM_1)) + if(!isPaused && !isEnd && !isIntro) { - if(!isPaused) { + if(Gdx.input.isKeyJustPressed(Input.Keys.NUM_1)) + { colourchangeSound.play(); player.setCurColour(Base.Colours.RED); + progressTexture = app.assets.get("textures/player_red.png", Texture.class); } - } - if(Gdx.input.isKeyJustPressed(Input.Keys.NUM_2)) - { - if(!isPaused) { + if(Gdx.input.isKeyJustPressed(Input.Keys.NUM_2)) + { colourchangeSound.play(); player.setCurColour(Base.Colours.GREEN); + progressTexture = app.assets.get("textures/player_green.png", Texture.class); } - } - if(Gdx.input.isKeyJustPressed(Input.Keys.NUM_3)) { - if (!isPaused) { + if(Gdx.input.isKeyJustPressed(Input.Keys.NUM_3)) { colourchangeSound.play(); player.setCurColour(Base.Colours.BLUE); + progressTexture = app.assets.get("textures/player_blue.png", Texture.class); } - } - if(Gdx.input.isKeyJustPressed(Input.Keys.NUM_4)) - { - if(!isPaused) { + + if(Gdx.input.isKeyJustPressed(Input.Keys.NUM_4)) + { player.setCurColour(Base.Colours.YELLOW); + progressTexture = app.assets.get("textures/player_yellow.png", Texture.class); } + } if(Gdx.input.isKeyJustPressed(Input.Keys.V)) { isDebug = !isDebug; } @@ -490,6 +493,7 @@ public class Play extends AbstractScreen { { isEnd = true; isSuccess = true; + System.out.println("Success"); return; } @@ -498,6 +502,7 @@ public class Play extends AbstractScreen { { isEnd = true; isSuccess = false; + System.out.println("Failure"); return; }