basic map

This commit is contained in:
Tim
2021-06-17 11:26:42 +02:00
parent 562738007c
commit bc4106efba
61 changed files with 140068 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
package main;
public class Launcher {
public static void main(String[] args) {
new Main();
}
}

View File

@@ -0,0 +1,23 @@
package main;
import ea.Game;
public class Main extends Game {
private World world;
public static final int WIDTH = 1056;
public static final int HEIGHT = 672;
public Main() {
super(WIDTH, HEIGHT);
world = new World();
wurzel.add(world);
}
@Override
public void tasteReagieren(int code) {
}
}

View File

@@ -0,0 +1,20 @@
package main;
import ea.Knoten;
public class Map extends Knoten {
private Tile[][] map;
public Map() {
map = new Tile[11][7];
for (int x = 0; x < map.length; x++) {
for (int y = 0; y < map[0].length; y++) {
map[x][y] = new Tile((x == 0 || y == 0 || x == map.length - 1 || y == map[0].length - 1) ? 1 : 0);
map[x][y].setX(x * 96);
map[x][y].setY(y * 96);
add(map[x][y]);
}
}
}
}

View File

@@ -0,0 +1,27 @@
package main;
import ea.Bild;
import ea.Knoten;
public class Tile extends Knoten {
public static final int GRASS = 0;
public static final int WALL = 1;
private Bild img;
public Tile(int id) {
img = new Bild(getPathFromId(id));
add(img);
}
private String getPathFromId(int id) {
switch (id) {
case GRASS:
return "res/images/grass.png";
case WALL:
return "res/images/stone.png";
}
return null;
}
}

View File

@@ -0,0 +1,14 @@
package main;
import ea.Knoten;
public class World extends Knoten {
private Map currentMap;
public World() {
currentMap = new Map();
add(currentMap);
}
}