This commit is contained in:
Asecave
2021-06-23 21:21:30 +02:00
5 changed files with 29 additions and 4 deletions

View File

@@ -17,6 +17,7 @@ public class Tile extends Knoten {
public static final int GRASS = 0; public static final int GRASS = 0;
public static final int WALL_TOP = 1; public static final int WALL_TOP = 1;
public static final int WALL_BOTTOM = 2; public static final int WALL_BOTTOM = 2;
public static final int STONE_WALL = 3;
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
@@ -60,6 +61,8 @@ public class Tile extends Knoten {
return "/res/images/tiles/wall_top.png"; return "/res/images/tiles/wall_top.png";
case WALL_BOTTOM: case WALL_BOTTOM:
return "/res/images/tiles/wall_bottom.png"; return "/res/images/tiles/wall_bottom.png";
case STONE_WALL:
return "/res/images/tiles/stone_wall.png";
} }
return null; return null;
} }
@@ -77,7 +80,7 @@ public class Tile extends Knoten {
public boolean isCollidable() { public boolean isCollidable() {
// Alle Tiles durch die man nicht laufen soll müssen hier true zurückgeben, // Alle Tiles durch die man nicht laufen soll müssen hier true zurückgeben,
// sonst werden sie bei der Collisiondetection nicht berücksichtigt. // sonst werden sie bei der Collisiondetection nicht berücksichtigt.
return id == WALL_TOP; return id == WALL_TOP || id == STONE_WALL ;
} }
/** /**

View File

@@ -4,9 +4,9 @@ import ea.Knoten;
import main.entities.Entity; import main.entities.Entity;
import main.entities.Player; import main.entities.Player;
import main.entities.Snake; import main.entities.Snake;
import main.maps.Corridor;
import main.entities.Spider; import main.entities.Spider;
import main.maps.Map; import main.maps.Map;
import main.maps.TestMap;
/** /**
* Hier werden alle Maps gespeichert. * Hier werden alle Maps gespeichert.
@@ -21,8 +21,8 @@ public class World extends Knoten {
public World() { public World() {
// Map initialisieren // Map initialisieren
currentMap = new TestMap(); currentMap = new Corridor();
// Map zu EA hinzufügen // Map zu EA hinzuf<EFBFBD>gen
add(currentMap); add(currentMap);
// und Entities auch // und Entities auch

View File

@@ -0,0 +1,22 @@
package main.maps;
import main.Tile;
public class Corridor extends Map {
public Corridor() {
super(5, 10);
for (int x = 0; x < map.length; x++) {
for (int y = 0; y < map[0].length; y++) {
if((y == 0 || x == 0 || y == 9 || x == 4) && x != 2 ) {
map[x][y] = new Tile(3, x, y);
add(map[x][y]);
} else {
map[x][y] = new Tile(0, x, y);
add(map[x][y]);
}
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 B