From 1c55813d853a3b3b369f565efa1aba6ce26a6e80 Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Fri, 1 Apr 2022 13:10:40 +0200 Subject: [PATCH] Calculate max amount of rendered chunks based on window size --- .idea/runConfigurations.xml | 10 ---------- .../java/com/yes/yes/behaviours/PlaceBehaviour.java | 6 +----- src/main/java/com/yes/yes/managers/PlayerManager.java | 8 +++----- .../classes/main/resources/com/yes/yes/main-view.fxml | 6 ++++++ 4 files changed, 10 insertions(+), 20 deletions(-) delete mode 100644 .idea/runConfigurations.xml create mode 100644 target/classes/main/resources/com/yes/yes/main-view.fxml diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 797acea..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/main/java/com/yes/yes/behaviours/PlaceBehaviour.java b/src/main/java/com/yes/yes/behaviours/PlaceBehaviour.java index 335d538..345d43c 100644 --- a/src/main/java/com/yes/yes/behaviours/PlaceBehaviour.java +++ b/src/main/java/com/yes/yes/behaviours/PlaceBehaviour.java @@ -5,10 +5,6 @@ import com.yes.yes.utils.*; public class PlaceBehaviour extends Component { - /** - * @param entity - * @param blockContainer - */ public PlaceBehaviour(Entity entity, BlockContainer blockContainer) { super(entity, blockContainer); } @@ -34,7 +30,7 @@ public class PlaceBehaviour extends Component { item.setPart(i, i1, new Square()); } } - parent.getChildren().add(item); + // parent.getChildren().add(item); } @Override diff --git a/src/main/java/com/yes/yes/managers/PlayerManager.java b/src/main/java/com/yes/yes/managers/PlayerManager.java index ea62bbf..9b02ec7 100644 --- a/src/main/java/com/yes/yes/managers/PlayerManager.java +++ b/src/main/java/com/yes/yes/managers/PlayerManager.java @@ -76,12 +76,10 @@ public class PlayerManager { double offset = Chunk.CHUNK_SIZE * Chunk.ENTITY_SIZE; + int loadedChunksX = (int) Math.ceil(world.getScene().getWidth() / Chunk.CHUNK_SIZE / Chunk.ENTITY_SIZE) + 1; + int loadedChunksY = (int) Math.ceil(world.getScene().getHeight() / Chunk.CHUNK_SIZE / Chunk.ENTITY_SIZE) + 1; - //TODO: Calculate amount of chunks based on window size - - int loadedChunksX = 5; - int loadedChunksY = 5; - + System.out.println("X:" + loadedChunksX + " Y:" + loadedChunksY); int chunkX = -(int) Math.floor((world.getTranslateX() + offset) / Chunk.CHUNK_SIZE / Chunk.ENTITY_SIZE); int chunkY = -(int) Math.floor((world.getTranslateY() + offset) / Chunk.CHUNK_SIZE / Chunk.ENTITY_SIZE); diff --git a/target/classes/main/resources/com/yes/yes/main-view.fxml b/target/classes/main/resources/com/yes/yes/main-view.fxml new file mode 100644 index 0000000..7624817 --- /dev/null +++ b/target/classes/main/resources/com/yes/yes/main-view.fxml @@ -0,0 +1,6 @@ + + + + +