forked from IF-LK-2020/zulda
basic map
This commit is contained in:
8
workspace/Zulda/src/main/Launcher.java
Normal file
8
workspace/Zulda/src/main/Launcher.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package main;
|
||||
|
||||
public class Launcher {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Main();
|
||||
}
|
||||
}
|
||||
23
workspace/Zulda/src/main/Main.java
Normal file
23
workspace/Zulda/src/main/Main.java
Normal 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) {
|
||||
|
||||
}
|
||||
}
|
||||
20
workspace/Zulda/src/main/Map.java
Normal file
20
workspace/Zulda/src/main/Map.java
Normal 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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
workspace/Zulda/src/main/Tile.java
Normal file
27
workspace/Zulda/src/main/Tile.java
Normal 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;
|
||||
}
|
||||
}
|
||||
14
workspace/Zulda/src/main/World.java
Normal file
14
workspace/Zulda/src/main/World.java
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user