Skip to content

Commit

Permalink
bug fix in rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
thatshawt committed May 12, 2022
1 parent d38d21a commit 00b6c12
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,8 @@ private void drawUILayer(Graphics g){
g.setFont(UI_FONT);

for(TileChunk chunk :
chunks.chunksWithinRenderDistance(getX(),getY(), player.getCamera().getRenderDistance())){
chunks.chunksWithinRenderDistance(
player.getX(), player.getY(), player.getCamera().getRenderDistance())){
for(Entity entity : chunk.entityList){
if(entity instanceof Player) {
Player playerEntity = (Player)entity;
Expand Down
11 changes: 4 additions & 7 deletions GameCore/src/main/java/me/thatshawt/gameCore/game/Entity.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package me.thatshawt.gameCore.game;

import me.thatshawt.gameCore.tile.ChunkCoord;
import me.thatshawt.gameCore.tile.ChunkMap;
import me.thatshawt.gameCore.tile.Tile;
import me.thatshawt.gameCore.tile.TileChunk;
import me.thatshawt.gameCore.tile.*;

import java.io.Serializable;
import java.util.UUID;
Expand Down Expand Up @@ -65,9 +62,9 @@ protected void updateChunkLocation(int oldX, int oldY, int newX, int newY){
TileChunk previousChunk = chunks.get(ChunkCoord.fromTileXY(oldX, oldY));
TileChunk newChunk = chunks.get(ChunkCoord.fromTileXY(newX, newY));
if(newChunk != previousChunk){
System.out.println("moved entity " + this + " from " + previousChunk + " to " + newChunk);
previousChunk.removeEntity(this);
// System.out.println("moved entity " + this + " from " + previousChunk + " to " + newChunk);
newChunk.addEntity(this);
previousChunk.removeEntity(this);
}
}

Expand All @@ -85,7 +82,7 @@ protected void updateChunkLocation(int oldX, int oldY, int newX, int newY){
*/
public boolean checkCollision(Direction direction){
Tile target = chunks.tileAt(getX() + direction.xOffset, getY() + direction.yOffset);
return target != null;
return target instanceof AirTile;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package me.thatshawt.gameCore.tile;

public class ChunkGenerator {



}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ private TileChunk(int size){
}
}

public static final int CHUNK_SIZE = 4;
public static final int CHUNK_SIZE = 8;

public TileChunk(){
this(CHUNK_SIZE);//idk cool size i guess
this(CHUNK_SIZE);
}

public void addEntity(Entity entity){
Expand Down

0 comments on commit 00b6c12

Please sign in to comment.