This commit is contained in:
2021-06-28 22:56:58 +02:00
24 changed files with 50 additions and 27 deletions

View File

@@ -29,7 +29,6 @@ public class DoorTile extends Tile implements Ticker {
if (dist < 0.5f) { if (dist < 0.5f) {
if (!waitForLeave) { if (!waitForLeave) {
Main.instance.getWorld().changeMap(this); Main.instance.getWorld().changeMap(this);
waitForLeave = true;
} }
} else { } else {
waitForLeave = false; waitForLeave = false;
@@ -62,10 +61,15 @@ public class DoorTile extends Tile implements Ticker {
} }
@Override @Override
public Tile clone() { public DoorTile clone() {
DoorTile t = new DoorTile(posX, posY, map); DoorTile t = new DoorTile(posX, posY, map);
t.setConnectedDoor(connected); t.setConnectedDoor(connected);
t.side = side; t.side = side;
t.map = map;
return t; return t;
} }
public void setMap(ImageMap map) {
this.map = map;
}
} }

View File

@@ -22,9 +22,12 @@ public class Tile extends Knoten {
public static final int STONE_WALL_BOTTOM = 4; public static final int STONE_WALL_BOTTOM = 4;
public static final int STONE_FLOOR = 5; public static final int STONE_FLOOR = 5;
public static final int DOOR = 6; public static final int DOOR = 6;
public static final int STONE_FLOOR_SHADOW_LEFT = 7;
public static final int DOOR_LEFT_BOTTOM = 8;
public static final int DOOR_LEFT_TOP = 9;
private Bild img; // Bild, das gerendert wird private Bild img; // Bild, das gerendert wird
private int id; // Die id dises Tiles private int id; // Die id dises Tiles//
protected float posX, posY; // Position dieses Tiles protected float posX, posY; // Position dieses Tiles
private static Bild[] images; private static Bild[] images;
@@ -53,7 +56,7 @@ public class Tile extends Knoten {
} }
private static void loadImages() { private static void loadImages() {
images = new Bild[7]; images = new Bild[10];
for (int i = 0; i < images.length; i++) { for (int i = 0; i < images.length; i++) {
try { try {
BufferedImage buff = ImageIO.read(Tile.class.getResourceAsStream(getPathFromId(i))); BufferedImage buff = ImageIO.read(Tile.class.getResourceAsStream(getPathFromId(i)));
@@ -62,9 +65,6 @@ public class Tile extends Knoten {
if (i == GRASS) { if (i == GRASS) {
buff = buff.getSubimage(16 * (int) (Math.random() * 8), 0, 16, 16); buff = buff.getSubimage(16 * (int) (Math.random() * 8), 0, 16, 16);
} }
// if (id == STONE_FLOOR) {
// buff = buff.getSubimage(16 * (int) (Math.random() * 10), 0, 16, 16);
// }
// Skalieren // Skalieren
BufferedImage scaled = new BufferedImage(World.SCALE, World.SCALE, BufferedImage.TYPE_INT_RGB); BufferedImage scaled = new BufferedImage(World.SCALE, World.SCALE, BufferedImage.TYPE_INT_RGB);
scaled.getGraphics().drawImage(buff, 0, 0, World.SCALE, World.SCALE, null); scaled.getGraphics().drawImage(buff, 0, 0, World.SCALE, World.SCALE, null);
@@ -93,7 +93,13 @@ public class Tile extends Knoten {
case STONE_FLOOR: case STONE_FLOOR:
return "/res/images/tiles/TestTest.png"; return "/res/images/tiles/TestTest.png";
case DOOR: case DOOR:
return "/res/images/tiles/door.png"; return "/res/images/tiles/door_left_bottom.png";
case STONE_FLOOR_SHADOW_LEFT:
return "/res/images/tiles/stone_floor_shadow_left.png";
case DOOR_LEFT_BOTTOM:
return "/res/images/tiles/door_left_bottom.png";
case DOOR_LEFT_TOP:
return "/res/images/tiles/door_left_top.png";
} }
return null; return null;
} }

View File

@@ -24,14 +24,12 @@ public class World extends Knoten {
dungeon = new ArrayList<>(50); dungeon = new ArrayList<>(50);
ImageMap start = new ImageMap("/res/images/maps/map2.png"); ImageMap start = new ImageMap("/res/images/maps/map2a.png");
dungeon.add(start); dungeon.add(start);
currentMap = start; currentMap = start;
currentMap.start();
start.generate(dungeon, DoorTile.BOTTOM); start.generate(dungeon, DoorTile.BOTTOM);
System.out.println("generated!"); System.out.println("generated!");
currentMap.start();
player = new Player(); player = new Player();
currentMap.getEntities().add(player); currentMap.getEntities().add(player);
@@ -55,10 +53,10 @@ public class World extends Knoten {
currentMap.entfernen(player.actionFigur); currentMap.entfernen(player.actionFigur);
entfernen(currentMap); entfernen(currentMap);
currentMap = door.getConnectedDoor().getMap(); currentMap = door.getConnectedDoor().getMap();
currentMap.add(player.actionFigur);
add(currentMap); add(currentMap);
currentMap.add(player.actionFigur);
currentMap.start(); currentMap.start();
door.getConnectedDoor().waitForLeave();
player.setPos(door.getConnectedDoor().posX + 0.5f, door.getConnectedDoor().posY + 0.5f); player.setPos(door.getConnectedDoor().posX + 0.5f, door.getConnectedDoor().posY + 0.5f);
door.getConnectedDoor().waitForLeave();
} }
} }

View File

@@ -13,9 +13,13 @@ import main.Tile;
public class ImageMap extends Map { public class ImageMap extends Map {
//Erstellung der abzulesenden Tiles (einem Tile wird eine farbe zugewiesen)
private static PixelTile[] pixels = { new PixelTile(Tile.STONE_WALL, new Color(100, 100, 100)), private static PixelTile[] pixels = { new PixelTile(Tile.STONE_WALL, new Color(100, 100, 100)),
new PixelTile(Tile.STONE_FLOOR, new Color(127, 127, 127)), new PixelTile(Tile.VOID, new Color(0, 0, 0)), new PixelTile(Tile.STONE_FLOOR, new Color(127, 127, 127)), new PixelTile(Tile.VOID, new Color(0, 0, 0)),
new PixelTile(Tile.DOOR, new Color(255, 0, 0)) }; new PixelTile(Tile.DOOR, new Color(255, 0, 0)), new PixelTile(Tile.DOOR_LEFT_TOP, new Color(255, 150, 0)) ,
new PixelTile(Tile.DOOR_LEFT_BOTTOM, new Color(69, 150, 0)), new PixelTile(Tile.STONE_WALL_BOTTOM, new Color(145, 145, 145)),
new PixelTile(Tile.STONE_FLOOR_SHADOW_LEFT, new Color(251, 251, 129))};
public DoorTile topDoor; public DoorTile topDoor;
public DoorTile leftDoor; public DoorTile leftDoor;
@@ -27,7 +31,8 @@ public class ImageMap extends Map {
static { static {
maps = new ImageMap[8]; maps = new ImageMap[8];
for (int i = 0; i < maps.length; i++) { for (int i = 0; i < maps.length; i++) {
maps[i] = new ImageMap("/res/images/maps/map" + (i + 1) + ".png"); System.out.println("/res/images/maps/map" + (i + 1) + "a.png");
maps[i] = new ImageMap("/res/images/maps/map" + (i + 1) + "a.png");
} }
} }
@@ -49,7 +54,14 @@ public class ImageMap extends Map {
break; break;
} }
} }
if (id == Tile.DOOR) { if (id == Tile.DOOR_LEFT_BOTTOM) {
DoorTile door = new DoorTile(x, y, this);
tiles[x][y] = door;
leftDoor = door;
door.setSide(DoorTile.LEFT);
}
if (id == Tile.DOOR ) {
DoorTile door = new DoorTile(x, y, this); DoorTile door = new DoorTile(x, y, this);
tiles[x][y] = door; tiles[x][y] = door;
if (x == 7) { if (x == 7) {
@@ -88,21 +100,24 @@ public class ImageMap extends Map {
tiles[x][y] = map.getTile(x, y).clone(); tiles[x][y] = map.getTile(x, y).clone();
if (tiles[x][y] instanceof DoorTile) { if (tiles[x][y] instanceof DoorTile) {
DoorTile dt = (DoorTile) tiles[x][y]; DoorTile dt = (DoorTile) tiles[x][y];
switch (dt.getSide()) { if (dt.getSide() == DoorTile.TOP) {
case DoorTile.TOP:
topDoor = dt; topDoor = dt;
break; topDoor.setMap(this);
case DoorTile.BOTTOM: }
if (dt.getSide() == DoorTile.BOTTOM) {
bottomDoor = dt; bottomDoor = dt;
break; bottomDoor.setMap(this);
case DoorTile.LEFT: }
if (dt.getSide() == DoorTile.LEFT) {
leftDoor = dt; leftDoor = dt;
break; leftDoor.setMap(this);
case DoorTile.RIGHT: }
if (dt.getSide() == DoorTile.RIGHT) {
rightDoor = dt; rightDoor = dt;
break; rightDoor.setMap(this);
} }
} }
add(tiles[x][y]);
} }
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 535 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 545 B

After

Width:  |  Height:  |  Size: 450 B