Tile code cleanup
This commit is contained in:
@@ -53,12 +53,9 @@ public class BlockRenderer implements Disposable{
|
||||
|
||||
Draw.color(shadowColor);
|
||||
|
||||
for(int x = 0; x < world.width(); x++){
|
||||
for(int y = 0; y < world.height(); y++){
|
||||
Tile tile = world.rawTile(x, y);
|
||||
if(tile.block().hasShadow){
|
||||
Fill.rect(tile.x + 0.5f, tile.y + 0.5f, 1, 1);
|
||||
}
|
||||
for(Tile tile : world.tiles){
|
||||
if(tile.block().hasShadow){
|
||||
Fill.rect(tile.x + 0.5f, tile.y + 0.5f, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,16 +69,12 @@ public class BlockRenderer implements Disposable{
|
||||
Core.graphics.clear(Color.white);
|
||||
Draw.proj().setOrtho(0, 0, fog.getWidth(), fog.getHeight());
|
||||
|
||||
for(int x = 0; x < world.width(); x++){
|
||||
for(int y = 0; y < world.height(); y++){
|
||||
Tile tile = world.rawTile(x, y);
|
||||
for(Tile tile : world.tiles){
|
||||
float darkness = world.getDarkness(tile.x, tile.y);
|
||||
|
||||
float darkness = world.getDarkness(x, y);
|
||||
|
||||
if(darkness > 0){
|
||||
Draw.color(0f, 0f, 0f, Math.min((darkness + 0.5f) / 4f, 1f));
|
||||
Fill.rect(tile.x + 0.5f, tile.y + 0.5f, 1, 1);
|
||||
}
|
||||
if(darkness > 0){
|
||||
Draw.color(0f, 0f, 0f, Math.min((darkness + 0.5f) / 4f, 1f));
|
||||
Fill.rect(tile.x + 0.5f, tile.y + 0.5f, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -170,13 +170,13 @@ public class MenuRenderer implements Disposable{
|
||||
Draw.proj().setOrtho(0, 0, shadows.getWidth(), shadows.getHeight());
|
||||
shadows.beginDraw(Color.clear);
|
||||
Draw.color(Color.black);
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int y = 0; y < height; y++){
|
||||
if(world.rawTile(x, y).block() != Blocks.air){
|
||||
Fill.rect(x + 0.5f, y + 0.5f, 1, 1);
|
||||
}
|
||||
|
||||
for(Tile tile : world.tiles){
|
||||
if(tile.block() != Blocks.air){
|
||||
Fill.rect(tile.x + 0.5f, tile.y + 0.5f, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
shadows.endDraw();
|
||||
|
||||
@@ -185,32 +185,19 @@ public class MenuRenderer implements Disposable{
|
||||
Core.batch = batch = new CacheBatch(new SpriteCache(width * height * 6, false));
|
||||
batch.beginCache();
|
||||
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int y = 0; y < height; y++){
|
||||
Tile tile = world.rawTile(x, y);
|
||||
tile.floor().draw(tile);
|
||||
}
|
||||
for(Tile tile : world.tiles){
|
||||
tile.floor().draw(tile);
|
||||
}
|
||||
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int y = 0; y < height; y++){
|
||||
Tile tile = world.rawTile(x, y);
|
||||
if(tile.overlay() != Blocks.air){
|
||||
tile.overlay().draw(tile);
|
||||
}
|
||||
}
|
||||
for(Tile tile : world.tiles){
|
||||
tile.overlay().draw(tile);
|
||||
}
|
||||
|
||||
cacheFloor = batch.endCache();
|
||||
batch.beginCache();
|
||||
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int y = 0; y < height; y++){
|
||||
Tile tile = world.rawTile(x, y);
|
||||
if(tile.block() != Blocks.air){
|
||||
tile.block().draw(tile);
|
||||
}
|
||||
}
|
||||
for(Tile tile : world.tiles){
|
||||
tile.block().draw(tile);
|
||||
}
|
||||
|
||||
cacheWall = batch.endCache();
|
||||
|
||||
@@ -128,10 +128,8 @@ public class MinimapRenderer implements Disposable{
|
||||
}
|
||||
|
||||
public void updateAll(){
|
||||
for(int x = 0; x < world.width(); x++){
|
||||
for(int y = 0; y < world.height(); y++){
|
||||
pixmap.draw(x, pixmap.getHeight() - 1 - y, colorFor(world.tile(x, y)));
|
||||
}
|
||||
for(Tile tile : world.tiles){
|
||||
pixmap.draw(tile.x, pixmap.getHeight() - 1 - tile.y, colorFor(tile));
|
||||
}
|
||||
texture.draw(pixmap, 0, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user