|
@@ -73,6 +73,11 @@ public class TileMapRenderer
|
|
{
|
|
{
|
|
return map.getHeight() * TileRenderer.TILE_SIZE * scale;
|
|
return map.getHeight() * TileRenderer.TILE_SIZE * scale;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private float toTexture(int x)
|
|
|
|
+ {
|
|
|
|
+ return x * TileRenderer.TILE_SIZE / TileTexture.TEXTURE_SIZE;
|
|
|
|
+ }
|
|
|
|
|
|
private void addTile(TextureRenderer tr, int x, int y, float tMinX, float tMinY, float tMaxX, float tMaxY)
|
|
private void addTile(TextureRenderer tr, int x, int y, float tMinX, float tMinY, float tMaxX, float tMaxY)
|
|
{
|
|
{
|
|
@@ -82,6 +87,11 @@ public class TileMapRenderer
|
|
tMinX + T_ERROR, tMinY + T_ERROR,
|
|
tMinX + T_ERROR, tMinY + T_ERROR,
|
|
tMaxX - T_ERROR, tMaxY - T_ERROR);
|
|
tMaxX - T_ERROR, tMaxY - T_ERROR);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private void addTileOverlay(TextureRenderer tr, int x, int y, int ox, int oy)
|
|
|
|
+ {
|
|
|
|
+ addTile(tr, x, y, toTexture(ox), toTexture(oy), toTexture(ox + 1), toTexture(oy + 1));
|
|
|
|
+ }
|
|
|
|
|
|
private boolean isInRange(TileMap map, int x, int y)
|
|
private boolean isInRange(TileMap map, int x, int y)
|
|
{
|
|
{
|
|
@@ -102,7 +112,7 @@ public class TileMapRenderer
|
|
TileRenderType type = map.getTile(x, y).getRenderType();
|
|
TileRenderType type = map.getTile(x, y).getRenderType();
|
|
return type == TileRenderType.SWAMP || type == TileRenderType.WATER;
|
|
return type == TileRenderType.SWAMP || type == TileRenderType.WATER;
|
|
}
|
|
}
|
|
-
|
|
+
|
|
private void addWaterSwampOverlay(TileMap map, int x, int y)
|
|
private void addWaterSwampOverlay(TileMap map, int x, int y)
|
|
{
|
|
{
|
|
boolean n = isSwamp(map, x, y - 1);
|
|
boolean n = isSwamp(map, x, y - 1);
|
|
@@ -112,19 +122,19 @@ public class TileMapRenderer
|
|
|
|
|
|
if(!n && !w && isSwamp(map, x - 1, y - 1))
|
|
if(!n && !w && isSwamp(map, x - 1, y - 1))
|
|
{
|
|
{
|
|
- addTile(swampWaterOverlayRenderer, x, y, 0.0f, 0.0f, 0.5f, 0.5f);
|
|
+ addTileOverlay(swampWaterOverlayRenderer, x, y, 7, 13);
|
|
}
|
|
}
|
|
if(!n && !e && isSwamp(map, x + 1, y - 1))
|
|
if(!n && !e && isSwamp(map, x + 1, y - 1))
|
|
{
|
|
{
|
|
- addTile(swampWaterOverlayRenderer, x, y, 0.0f, 0.0f, 0.5f, 0.5f);
|
|
+ addTileOverlay(swampWaterOverlayRenderer, x, y, 6, 13);
|
|
}
|
|
}
|
|
if(!s && !w && isSwamp(map, x - 1, y + 1))
|
|
if(!s && !w && isSwamp(map, x - 1, y + 1))
|
|
{
|
|
{
|
|
- addTile(swampWaterOverlayRenderer, x, y, 0.0f, 0.0f, 0.5f, 0.5f);
|
|
+ addTileOverlay(swampWaterOverlayRenderer, x, y, 5, 13);
|
|
}
|
|
}
|
|
if(!s && !e && isSwamp(map, x + 1, y + 1))
|
|
if(!s && !e && isSwamp(map, x + 1, y + 1))
|
|
{
|
|
{
|
|
- addTile(swampWaterOverlayRenderer, x, y, 0.0f, 0.0f, 0.5f, 0.5f);
|
|
+ addTileOverlay(swampWaterOverlayRenderer, x, y, 4, 13);
|
|
}
|
|
}
|
|
|
|
|
|
int index = 0;
|
|
int index = 0;
|
|
@@ -136,11 +146,7 @@ public class TileMapRenderer
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
+ addTileOverlay(swampWaterOverlayRenderer, x, y, index, 15);
|
|
- float tMinX = index * TileRenderer.TILE_SIZE / TileTexture.TEXTURE_SIZE;
|
|
|
|
- float tMaxX = (index + 1) * TileRenderer.TILE_SIZE / TileTexture.TEXTURE_SIZE;
|
|
|
|
-
|
|
|
|
- addTile(swampWaterOverlayRenderer, x, y, tMinX, 0.0f, tMaxX, 0.5f);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private void addGrassOverlay(TileMap map, int x, int y)
|
|
private void addGrassOverlay(TileMap map, int x, int y)
|
|
@@ -152,19 +158,19 @@ public class TileMapRenderer
|
|
|
|
|
|
if(n && w && !isSwampOrWaterOrBorder(map, x - 1, y - 1))
|
|
if(n && w && !isSwampOrWaterOrBorder(map, x - 1, y - 1))
|
|
{
|
|
{
|
|
- addTile(grassOverlayRenderer, x, y, 0.0f, 0.0f, 0.5f, 0.5f);
|
|
+ addTileOverlay(grassOverlayRenderer, x, y, 3, 13);
|
|
}
|
|
}
|
|
if(n && e && !isSwampOrWaterOrBorder(map, x + 1, y - 1))
|
|
if(n && e && !isSwampOrWaterOrBorder(map, x + 1, y - 1))
|
|
{
|
|
{
|
|
- addTile(grassOverlayRenderer, x, y, 0.0f, 0.0f, 0.5f, 0.5f);
|
|
+ addTileOverlay(grassOverlayRenderer, x, y, 2, 13);
|
|
}
|
|
}
|
|
if(s && w && !isSwampOrWaterOrBorder(map, x - 1, y + 1))
|
|
if(s && w && !isSwampOrWaterOrBorder(map, x - 1, y + 1))
|
|
{
|
|
{
|
|
- addTile(grassOverlayRenderer, x, y, 0.0f, 0.0f, 0.5f, 0.5f);
|
|
+ addTileOverlay(grassOverlayRenderer, x, y, 1, 13);
|
|
}
|
|
}
|
|
if(s && e && !isSwampOrWaterOrBorder(map, x + 1, y + 1))
|
|
if(s && e && !isSwampOrWaterOrBorder(map, x + 1, y + 1))
|
|
{
|
|
{
|
|
- addTile(grassOverlayRenderer, x, y, 0.0f, 0.0f, 0.5f, 0.5f);
|
|
+ addTileOverlay(grassOverlayRenderer, x, y, 0, 13);
|
|
}
|
|
}
|
|
|
|
|
|
int index = 0;
|
|
int index = 0;
|
|
@@ -177,9 +183,7 @@ public class TileMapRenderer
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- float tMinX = index * TileRenderer.TILE_SIZE / TileTexture.TEXTURE_SIZE;
|
|
+ addTileOverlay(grassOverlayRenderer, x, y, index, 14);
|
|
- float tMaxX = (index + 1) * TileRenderer.TILE_SIZE / TileTexture.TEXTURE_SIZE;
|
|
|
|
- addTile(grassOverlayRenderer, x, y, tMinX, 0.0f, tMaxX, 0.5f);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private void updateData(TileMap map)
|
|
private void updateData(TileMap map)
|
|
@@ -197,7 +201,7 @@ public class TileMapRenderer
|
|
{
|
|
{
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
-
|
|
+ if(t.getRenderType() == TileRenderType.WATER)
|
|
{
|
|
{
|
|
addWaterSwampOverlay(map, x, y);
|
|
addWaterSwampOverlay(map, x, y);
|
|
addGrassOverlay(map, x, y);
|
|
addGrassOverlay(map, x, y);
|
|
@@ -205,7 +209,7 @@ public class TileMapRenderer
|
|
else if(t.getRenderType() == TileRenderType.SWAMP)
|
|
else if(t.getRenderType() == TileRenderType.SWAMP)
|
|
{
|
|
{
|
|
addGrassOverlay(map, x, y);
|
|
addGrassOverlay(map, x, y);
|
|
- }*/
|
|
+ }
|
|
addTile(textureRenderer, x, y, tt.getMinX(), tt.getMinY(), tt.getMaxX(), tt.getMaxY());
|
|
addTile(textureRenderer, x, y, tt.getMinX(), tt.getMinY(), tt.getMaxX(), tt.getMaxY());
|
|
}
|
|
}
|
|
}
|
|
}
|