Calculate max amount of rendered chunks based on window size

This commit is contained in:
Stone_Red
2022-04-01 13:10:40 +02:00
parent 06e6c72dc3
commit 1c55813d85
4 changed files with 10 additions and 20 deletions
-10
View File
@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>
@@ -5,10 +5,6 @@ import com.yes.yes.utils.*;
public class PlaceBehaviour extends Component { public class PlaceBehaviour extends Component {
/**
* @param entity
* @param blockContainer
*/
public PlaceBehaviour(Entity entity, BlockContainer blockContainer) { public PlaceBehaviour(Entity entity, BlockContainer blockContainer) {
super(entity, blockContainer); super(entity, blockContainer);
} }
@@ -34,7 +30,7 @@ public class PlaceBehaviour extends Component {
item.setPart(i, i1, new Square()); item.setPart(i, i1, new Square());
} }
} }
parent.getChildren().add(item); // parent.getChildren().add(item);
} }
@Override @Override
@@ -76,12 +76,10 @@ public class PlayerManager {
double offset = Chunk.CHUNK_SIZE * Chunk.ENTITY_SIZE; 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 System.out.println("X:" + loadedChunksX + " Y:" + loadedChunksY);
int loadedChunksX = 5;
int loadedChunksY = 5;
int chunkX = -(int) Math.floor((world.getTranslateX() + offset) / Chunk.CHUNK_SIZE / Chunk.ENTITY_SIZE); 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); int chunkY = -(int) Math.floor((world.getTranslateY() + offset) / Chunk.CHUNK_SIZE / Chunk.ENTITY_SIZE);
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.VBox?>
<VBox spacing="20.0" xmlns:fx="http://javafx.com/fxml"
fx:controller="com.yes.yes.MainController" fx:id="root">
</VBox>