From 50b459acc04576ee877fd75b391f349c4ba7f893 Mon Sep 17 00:00:00 2001 From: GammelJAN Date: Sat, 23 Jan 2021 22:13:13 +0100 Subject: [PATCH] quest window wiggling removed --- core/src/com/trs/main/MapContainer.java | 8 -------- core/src/com/trs/main/view/UI/QuestWindow.java | 15 ++++++++------- core/src/com/trs/main/view/UI/UIDrawer.java | 9 +++++++-- .../src/com/trs/main/view/screens/GameScreen.java | 11 ++++++++++- .../src/com/trs/main/desktop/DesktopLauncher.java | 3 +-- 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/core/src/com/trs/main/MapContainer.java b/core/src/com/trs/main/MapContainer.java index 9caa81d..f365546 100644 --- a/core/src/com/trs/main/MapContainer.java +++ b/core/src/com/trs/main/MapContainer.java @@ -336,14 +336,6 @@ public class MapContainer { } } - // center camera - for(Actor a : getStage().getActors()){ - if(a instanceof Player){ - getStage().getCamera().position.set((a.getX()+a.getWidth()/2), (a.getY()+a.getHeight()/2), 0); - getStage().getCamera().update(); - break; - } - } if(getT() != null){ getT().draw(getStage().getBatch(), getStage().getCamera().position.x, getStage().getCamera().position.y, getStage().getCamera().combined); if(getT().opacity == 0){ diff --git a/core/src/com/trs/main/view/UI/QuestWindow.java b/core/src/com/trs/main/view/UI/QuestWindow.java index 6126b35..219c9a7 100644 --- a/core/src/com/trs/main/view/UI/QuestWindow.java +++ b/core/src/com/trs/main/view/UI/QuestWindow.java @@ -1,4 +1,4 @@ -/* + /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. @@ -27,6 +27,8 @@ import com.trs.main.Quest; public class QuestWindow { + final double animationSpeed = 0.05; + BitmapFont font; ShapeRenderer renderer; boolean visible; @@ -61,7 +63,7 @@ public class QuestWindow { } - float boxX = playerX + Main.CAMERA_WIDTH/2 - 0.2f*Main.CAMERA_WIDTH - 30; + float boxX = playerX + Main.CAMERA_WIDTH/2 - 200; float boxY = playerY + Main.CAMERA_HEIGHT/2 - 0.4f*Main.CAMERA_HEIGHT - 30; float boxWidth = 0.2f*Main.CAMERA_WIDTH; float boxHeight = 0.4f*Main.CAMERA_HEIGHT; @@ -70,7 +72,7 @@ public class QuestWindow { if(visible && Main.gamestate != 2){ if(visiblePerc < 1){ - visiblePerc += 0.2; + visiblePerc += animationSpeed; Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); renderer.begin(ShapeRenderer.ShapeType.Filled); @@ -110,14 +112,13 @@ public class QuestWindow { batch.end(); if(selectedQuest > 0){ - UIDrawer.drawCharBox(batch, font, boxX - 16 , boxY + boxHeight/2 - 16, 32, "<"); + UIDrawer.drawCharBox(batch, font, boxX - 16 , boxY + boxHeight/2 - 16, 32, "<"); } if(selectedQuest < quests.length-1){ - UIDrawer.drawCharBox(batch, font, boxX + boxWidth - 16 , boxY + boxHeight/2 - 16, 32, ">"); + UIDrawer.drawCharBox(batch, font, boxX + boxWidth - 16 , boxY + boxHeight/2 - 16, 32, ">"); } UIDrawer.drawCharBox(batch, font, boxX + boxWidth - 16 , boxY + boxHeight - 16, 32, "^"); - UIDrawer.drawIcon(batch, boxX + boxWidth/2, boxY + boxHeight, 0); Gdx.gl.glDisable(GL20.GL_BLEND); @@ -130,7 +131,7 @@ public class QuestWindow { } else{ if(visiblePerc > 0){ - visiblePerc -= 0.2; + visiblePerc -= animationSpeed; Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); renderer.begin(ShapeRenderer.ShapeType.Filled); diff --git a/core/src/com/trs/main/view/UI/UIDrawer.java b/core/src/com/trs/main/view/UI/UIDrawer.java index 8758f18..29c684d 100644 --- a/core/src/com/trs/main/view/UI/UIDrawer.java +++ b/core/src/com/trs/main/view/UI/UIDrawer.java @@ -12,6 +12,7 @@ import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.GlyphLayout; import com.badlogic.gdx.graphics.g2d.Sprite; +import com.sun.tools.javac.util.Abort; /** * @@ -19,6 +20,7 @@ import com.badlogic.gdx.graphics.g2d.Sprite; */ public class UIDrawer { + static Sprite box32 = new Sprite(new Texture(Gdx.files.internal("textureData/UI/box.png"))); static Texture questbook = new Texture(Gdx.files.internal("textureData/UI/questbook.png")); @@ -27,8 +29,7 @@ public class UIDrawer { font.setColor(Color.WHITE); switch(size){ case 16: - font.draw(batch, ""+character, x + 16 - getTextWidth(font, character)/2, y + 16 - getTextHeight(font, character)/2); - break; + throw new OutOfMemoryError("nice"); case 32: box32.setPosition(x, y); box32.draw(batch); @@ -36,6 +37,8 @@ public class UIDrawer { font.draw(batch, ""+character, x + 16 - getTextWidth(font, character)/2, y + 16 + (getTextHeight(font, character)/2) - 2); font.getData().setScale(1); break; + default: + throw new OutOfMemoryError("nice"); } batch.end(); @@ -47,6 +50,8 @@ public class UIDrawer { case 0: batch.draw(questbook, x - questbook.getWidth()/2, y - questbook.getHeight()/2); break; + default: + throw new Abort(); } batch.end(); diff --git a/core/src/com/trs/main/view/screens/GameScreen.java b/core/src/com/trs/main/view/screens/GameScreen.java index 658446a..1717285 100644 --- a/core/src/com/trs/main/view/screens/GameScreen.java +++ b/core/src/com/trs/main/view/screens/GameScreen.java @@ -41,14 +41,23 @@ public class GameScreen extends AbstractScreen{ @Override public void render(float f) { map.render(f); + Quest[] rects = new Quest[map.getPlayer().getQuests().size()]; for(int i = 0; i< map.getPlayer().getQuests().size(); i++){ rects[i] = map.getPlayer().getQuests().get(i); } - qw.draw(rects, map.getStage().getBatch(), map.getPlayer().getX()+32, map.getPlayer().getY()+32); + + //qw.draw(rects, map.getStage().getBatch(), map.getPlayer().getX()+32, map.getPlayer().getY()+32); + qw.draw(rects, map.getStage().getBatch(), map.getStage().getCamera().position.x, map.getStage().getCamera().position.y ); + if(map.getCollidingDoor() != null) { loadNewMap(map.getCollidingDoor().destinationMap, map.getCollidingDoor().destinationDoor); } + + + Player a = map.getPlayer(); + map.getStage().getCamera().position.set((a.getX()+a.getWidth()/2), (a.getY()+a.getHeight()/2), 0); + map.getStage().getCamera().update(); } @Override diff --git a/desktop/src/com/trs/main/desktop/DesktopLauncher.java b/desktop/src/com/trs/main/desktop/DesktopLauncher.java index c3d4302..f13696f 100644 --- a/desktop/src/com/trs/main/desktop/DesktopLauncher.java +++ b/desktop/src/com/trs/main/desktop/DesktopLauncher.java @@ -18,5 +18,4 @@ public class DesktopLauncher { //config.fullscreen = true; new LwjglApplication(new Main(), config); } -} - +} \ No newline at end of file