Skip to content

Commit

Permalink
Merge pull request #402 from maxkratt/main
Browse files Browse the repository at this point in the history
fix: fix connected tiles requiring flipped sprites
  • Loading branch information
Makkkkus authored Sep 26, 2022
2 parents 427c719 + a4199a4 commit 0d860b0
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 24 deletions.
24 changes: 12 additions & 12 deletions src/main/java/minicraft/gfx/ConnectorSprite.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,31 @@ public void render(Screen screen, Level level, int x, int y, int whiteTint) {


if (u && l) {
if (ul || !checkCorners) full.renderPixel(1, 1, screen, x, y);
else sides.renderPixel(0, 0, screen, x, y);
if (ul || !checkCorners) full.renderPixel(0, 0, screen, x, y);
else sides.renderPixel(1, 1, screen, x, y);
} else
sparse.renderPixel(l ? 1 : 2, u ? 1 : 2, screen, x, y);
sparse.renderPixel(l ? 1 : 0, u ? 1 : 0, screen, x, y);


if (u && r) {
if (ur || !checkCorners) full.renderPixel(0, 1, screen, x + 8, y);
else sides.renderPixel(1, 0, screen, x + 8, y);
if (ur || !checkCorners) full.renderPixel(1, 0, screen, x + 8, y);
else sides.renderPixel(0, 1, screen, x + 8, y);
} else
sparse.renderPixel(r ? 1 : 0, u ? 1 : 2, screen, x + 8, y);
sparse.renderPixel(r ? 1 : 2, u ? 1 : 0, screen, x + 8, y);


if (d && l) {
if (dl || !checkCorners) full.renderPixel(1, 0, screen, x, y + 8);
else sides.renderPixel(0, 1, screen, x, y + 8);
if (dl || !checkCorners) full.renderPixel(0, 1, screen, x, y + 8);
else sides.renderPixel(1, 0, screen, x, y + 8);
} else
sparse.renderPixel(l ? 1 : 2, d ? 1 : 0, screen, x, y + 8);
sparse.renderPixel(l ? 1 : 0, d ? 1 : 2, screen, x, y + 8);


if (d && r) {
if (dr || !checkCorners) full.renderPixel(0, 0, screen, x + 8, y + 8);
else sides.renderPixel(1, 1, screen, x + 8, y + 8);
if (dr || !checkCorners) full.renderPixel(1, 1, screen, x + 8, y + 8);
else sides.renderPixel(0, 0, screen, x + 8, y + 8);
} else
sparse.renderPixel(r ? 1 : 0, d ? 1 : 0, screen, x + 8, y + 8);
sparse.renderPixel(r ? 1 : 2, d ? 1 : 2, screen, x + 8, y + 8);

}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/minicraft/level/tile/CloudTile.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import minicraft.level.Level;

public class CloudTile extends Tile {
private static ConnectorSprite sprite = new ConnectorSprite(CloudTile.class, new Sprite(0, 22, 3, 3, 1, 3), new Sprite(3, 24, 2, 2, 1, 3), new Sprite(3, 22, 2, 2, 1))
private static ConnectorSprite sprite = new ConnectorSprite(CloudTile.class, new Sprite(0, 22, 3, 3, 1), new Sprite(3, 24, 2, 2, 1), new Sprite(3, 22, 2, 2, 1))
{
public boolean connectsTo(Tile tile, boolean isSide) {
return tile != Tiles.get("Infinite Fall");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/minicraft/level/tile/ExplodedTile.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/// This class is for tiles WHILE THEY ARE EXPLODING
public class ExplodedTile extends Tile {
private static ConnectorSprite sprite = new ConnectorSprite(ExplodedTile.class, new Sprite(6, 22, 3, 3, 1, 3), new Sprite(9, 22, 2, 2, 1))
private static ConnectorSprite sprite = new ConnectorSprite(ExplodedTile.class, new Sprite(6, 22, 3, 3, 1), new Sprite(9, 22, 2, 2, 1))
{
public boolean connectsTo(Tile tile, boolean isSide) {
return !isSide || tile.connectsToLiquid();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/minicraft/level/tile/GrassTile.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import minicraft.level.Level;

public class GrassTile extends Tile {
private static ConnectorSprite sprite = new ConnectorSprite(GrassTile.class, new Sprite(0, 6, 3, 3, 1, 3), new Sprite(3, 6, 2, 2, 1))
private static ConnectorSprite sprite = new ConnectorSprite(GrassTile.class, new Sprite(0, 6, 3, 3, 1), new Sprite(3, 6, 2, 2, 1))
{
public boolean connectsTo(Tile tile, boolean isSide) {
if(!isSide) return true;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/minicraft/level/tile/HardRockTile.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public class HardRockTile extends Tile {
// Theoretically the full sprite should never be used, so we can use a placeholder
private static ConnectorSprite sprite = new ConnectorSprite(HardRockTile.class, new Sprite(18, 9, 3, 3, 1, 3), new Sprite(21, 10, 2, 2, 1, 3), Sprite.missingTexture(2, 2));
private static ConnectorSprite sprite = new ConnectorSprite(HardRockTile.class, new Sprite(18, 9, 3, 3, 1), new Sprite(21, 10, 2, 2, 1), Sprite.missingTexture(2, 2));

protected HardRockTile(String name) {
super(name, sprite);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/minicraft/level/tile/HoleTile.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import minicraft.level.Level;

public class HoleTile extends Tile {
private static ConnectorSprite sprite = new ConnectorSprite(HoleTile.class, new Sprite(24, 6, 3, 3, 1, 3), new Sprite(27, 6, 2, 2, 1))
private static ConnectorSprite sprite = new ConnectorSprite(HoleTile.class, new Sprite(24, 6, 3, 3, 1), new Sprite(27, 6, 2, 2, 1))
{
public boolean connectsTo(Tile tile, boolean isSide) {
return tile.connectsToLiquid();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/minicraft/level/tile/LavaTile.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import minicraft.level.Level;

public class LavaTile extends Tile {
private ConnectorSprite sprite = new ConnectorSprite(LavaTile.class, new Sprite(12, 9, 3, 3, 1, 3), Sprite.dots(0))
private ConnectorSprite sprite = new ConnectorSprite(LavaTile.class, new Sprite(12, 9, 3, 3, 1), Sprite.dots(0))
{
public boolean connectsTo(Tile tile, boolean isSide) {
return tile.connectsToFluid;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/minicraft/level/tile/RockTile.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// This is the normal stone you see underground and on the surface, that drops coal and stone.

public class RockTile extends Tile {
private ConnectorSprite sprite = new ConnectorSprite(RockTile.class, new Sprite(18, 6, 3, 3, 1, 3), new Sprite(21, 8, 2, 2, 1, 3), new Sprite(21, 6, 2, 2, 1, 3));
private ConnectorSprite sprite = new ConnectorSprite(RockTile.class, new Sprite(18, 6, 3, 3, 1), new Sprite(21, 8, 2, 2, 1), new Sprite(21, 6, 2, 2, 1));

private boolean dropCoal = false;
private int maxHealth = 50;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/minicraft/level/tile/SandTile.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class SandTile extends Tile {
steppedOn = new Sprite(pixels);
}

private ConnectorSprite sprite = new ConnectorSprite(SandTile.class, new Sprite(6, 6, 3, 3, 1, 3), normal)
private ConnectorSprite sprite = new ConnectorSprite(SandTile.class, new Sprite(6, 6, 3, 3, 1), normal)
{
public boolean connectsTo(Tile tile, boolean isSide) {
if(!isSide) return true;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/minicraft/level/tile/WallTile.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ protected WallTile(Material type) {
super(type.name() + " Wall", (ConnectorSprite) null);
this.type = type;
switch (type) {
case Wood: sprite = new ConnectorSprite(WallTile.class, new Sprite(0, 14, 3, 3, 1, 3), new Sprite(3, 14, 2, 2, 1, 3), new Sprite(1, 15, 2, 2, 1, 0, true)); break;
case Stone: sprite = new ConnectorSprite(WallTile.class, new Sprite(10, 14, 3, 3, 1, 3), new Sprite(13, 14, 2, 2, 1, 3), new Sprite(11, 15, 2, 2, 1, 0, true)); break;
case Obsidian: sprite = new ConnectorSprite(WallTile.class, new Sprite(20, 14, 3, 3, 1, 3), new Sprite(23, 14, 2, 2, 1, 3), new Sprite(21, 15, 2, 2, 1, 0, true)); break;
case Wood: sprite = new ConnectorSprite(WallTile.class, new Sprite(0, 14, 3, 3, 1), new Sprite(3, 14, 2, 2, 1), new Sprite(1, 15, 2, 2, 1, 0, true)); break;
case Stone: sprite = new ConnectorSprite(WallTile.class, new Sprite(10, 14, 3, 3, 1), new Sprite(13, 14, 2, 2, 1), new Sprite(11, 15, 2, 2, 1, 0, true)); break;
case Obsidian: sprite = new ConnectorSprite(WallTile.class, new Sprite(20, 14, 3, 3, 1), new Sprite(23, 14, 2, 2, 1), new Sprite(21, 15, 2, 2, 1, 0, true)); break;
}
csprite = sprite;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/minicraft/level/tile/WaterTile.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import minicraft.level.Level;

public class WaterTile extends Tile {
private ConnectorSprite sprite = new ConnectorSprite(WaterTile.class, new Sprite(12, 6, 3, 3, 1, 3), Sprite.dots(/*Color.get(005, 105, 115, 115)*/ 0))
private ConnectorSprite sprite = new ConnectorSprite(WaterTile.class, new Sprite(12, 6, 3, 3, 1), Sprite.dots(/*Color.get(005, 105, 115, 115)*/ 0))
{
public boolean connectsTo(Tile tile, boolean isSide) {
return tile.connectsToFluid;
Expand Down
Binary file modified src/main/resources/resources/textures/tiles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0d860b0

Please sign in to comment.