This commit is contained in:
Maxim Derksen 2021-06-28 22:56:58 +02:00
commit 0b521ca667
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 (!waitForLeave) {
Main.instance.getWorld().changeMap(this);
waitForLeave = true;
}
} else {
waitForLeave = false;
@ -62,10 +61,15 @@ public class DoorTile extends Tile implements Ticker {
}
@Override
public Tile clone() {
public DoorTile clone() {
DoorTile t = new DoorTile(posX, posY, map);
t.setConnectedDoor(connected);
t.side = side;
t.map = map;
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_FLOOR = 5;
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 int id; // Die id dises Tiles
private int id; // Die id dises Tiles//
protected float posX, posY; // Position dieses Tiles
private static Bild[] images;
@ -53,7 +56,7 @@ public class Tile extends Knoten {
}
private static void loadImages() {
images = new Bild[7];
images = new Bild[10];
for (int i = 0; i < images.length; i++) {
try {
BufferedImage buff = ImageIO.read(Tile.class.getResourceAsStream(getPathFromId(i)));
@ -62,9 +65,6 @@ public class Tile extends Knoten {
if (i == GRASS) {
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
BufferedImage scaled = new BufferedImage(World.SCALE, World.SCALE, BufferedImage.TYPE_INT_RGB);
scaled.getGraphics().drawImage(buff, 0, 0, World.SCALE, World.SCALE, null);
@ -93,7 +93,13 @@ public class Tile extends Knoten {
case STONE_FLOOR:
return "/res/images/tiles/TestTest.png";
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;
}

View File

@ -24,14 +24,12 @@ public class World extends Knoten {
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);
currentMap = start;
currentMap.start();
start.generate(dungeon, DoorTile.BOTTOM);
System.out.println("generated!");
currentMap.start();
player = new Player();
currentMap.getEntities().add(player);
@ -55,10 +53,10 @@ public class World extends Knoten {
currentMap.entfernen(player.actionFigur);
entfernen(currentMap);
currentMap = door.getConnectedDoor().getMap();
currentMap.add(player.actionFigur);
add(currentMap);
currentMap.add(player.actionFigur);
currentMap.start();
door.getConnectedDoor().waitForLeave();
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 {
//Erstellung der abzulesenden Tiles (einem Tile wird eine farbe zugewiesen)
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.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 leftDoor;
@ -27,7 +31,8 @@ public class ImageMap extends Map {
static {
maps = new ImageMap[8];
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;
}
}
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);
tiles[x][y] = door;
if (x == 7) {
@ -88,21 +100,24 @@ public class ImageMap extends Map {
tiles[x][y] = map.getTile(x, y).clone();
if (tiles[x][y] instanceof DoorTile) {
DoorTile dt = (DoorTile) tiles[x][y];
switch (dt.getSide()) {
case DoorTile.TOP:
if (dt.getSide() == DoorTile.TOP) {
topDoor = dt;
break;
case DoorTile.BOTTOM:
topDoor.setMap(this);
}
if (dt.getSide() == DoorTile.BOTTOM) {
bottomDoor = dt;
break;
case DoorTile.LEFT:
bottomDoor.setMap(this);
}
if (dt.getSide() == DoorTile.LEFT) {
leftDoor = dt;
break;
case DoorTile.RIGHT:
leftDoor.setMap(this);
}
if (dt.getSide() == DoorTile.RIGHT) {
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