start to implement gamemodi
This commit is contained in:
parent
b0043fe89e
commit
7bb50b7275
File diff suppressed because it is too large
Load Diff
@ -61,7 +61,10 @@ public class CRGameWorld implements GameInputListener {
|
||||
Gdx.input.setCatchBackKey(true);
|
||||
if(Gdx.input.isKeyPressed(Input.Keys.BACK) || Gdx.input.isKeyPressed(Input.Keys.BACKSPACE)) {
|
||||
Gdx.input.setCatchBackKey(false);
|
||||
((Game) Gdx.app.getApplicationListener()).setScreen(new EndlessGameMenu(music));
|
||||
if(mapprovider.isNextEndlessMenu())
|
||||
((Game) Gdx.app.getApplicationListener()).setScreen(new EndlessGameMenu(music));
|
||||
else
|
||||
((Game) Gdx.app.getApplicationListener()).setScreen(new MainMenu());
|
||||
}
|
||||
|
||||
for (int i = entities.size()-1; i >= 0; i--) {
|
||||
@ -83,7 +86,7 @@ public class CRGameWorld implements GameInputListener {
|
||||
checkHighscore();
|
||||
setTries();
|
||||
setLastBest();
|
||||
CRGame.Inst().setScreen(new GameScreen(new EndlessMapProvider(System.currentTimeMillis())));
|
||||
CRGame.Inst().setScreen(new GameScreen(this.mapprovider.createNew()));
|
||||
music.stop();
|
||||
}
|
||||
|
||||
|
@ -17,16 +17,21 @@ public class CRTiledMap {
|
||||
public final static int GID_EMPTY_1 = 0;
|
||||
public final static int GID_EMPTY_2 = 1;
|
||||
|
||||
public final static int GID_MID = 13;
|
||||
public final static int GID_UP = 8;
|
||||
public final static int GID_RIGHT = 14;
|
||||
public final static int GID_DOWN = 18;
|
||||
public final static int GID_LEFT = 12;
|
||||
public final static int GID_MID = 23;
|
||||
public final static int GID_UP = 13;
|
||||
public final static int GID_RIGHT = 24;
|
||||
public final static int GID_DOWN = 33;
|
||||
public final static int GID_LEFT = 22;
|
||||
public final static int GID_INTER_UP = 16;
|
||||
public final static int GID_INTER_DOWN = 17;
|
||||
public final static int GID_INTER_RIGHT = 18;
|
||||
|
||||
public int width;
|
||||
public int height;
|
||||
|
||||
public int[][] map;
|
||||
public int[][] interaktionen;
|
||||
|
||||
public String name;
|
||||
|
||||
public static CRTiledMap load(String name, String inputXmlString) {
|
||||
@ -34,23 +39,45 @@ public class CRTiledMap {
|
||||
|
||||
XmlReader reader = new XmlReader();
|
||||
Element root = reader.parse(inputXmlString);
|
||||
|
||||
Element elemLayer = root.getChildByName("layer");
|
||||
Element elemData = elemLayer.getChildByName("data");
|
||||
Array<Element> tiles = elemData.getChildrenByName("tile");
|
||||
|
||||
int width = elemLayer.getInt("width");
|
||||
int height = elemLayer.getInt("height");
|
||||
|
||||
int width = root.getInt("width");
|
||||
int height = root.getInt("height");
|
||||
|
||||
result.interaktionen = new int [width][height];
|
||||
result.map = new int[width][height];
|
||||
result.width = width;
|
||||
result.height = height;
|
||||
result.name = name;
|
||||
|
||||
for (int i = 0; i < tiles.size; i++) {
|
||||
result.map[i % width][i / width] = tiles.get(i).getInt("gid");
|
||||
|
||||
Array<Element> elemLayers = root.getChildrenByName("layer");
|
||||
|
||||
for (Element elemLayer:elemLayers) {
|
||||
|
||||
if(elemLayer.getAttribute("name").equalsIgnoreCase("Kachelebene"))
|
||||
{
|
||||
root.getChildrenByName("layer");
|
||||
Element elemData = elemLayer.getChildByName("data");
|
||||
Array<Element> tiles = elemData.getChildrenByName("tile");
|
||||
|
||||
for (int i = 0; i < tiles.size; i++) {
|
||||
result.map[i % width][i / width] = tiles.get(i).getInt("gid");
|
||||
}
|
||||
}
|
||||
else if(elemLayer.getAttribute("name").equalsIgnoreCase("Interaktionen"))
|
||||
{
|
||||
root.getChildrenByName("layer");
|
||||
Element elemData = elemLayer.getChildByName("data");
|
||||
Array<Element> tiles = elemData.getChildrenByName("tile");
|
||||
|
||||
for (int i = 0; i < tiles.size; i++) {
|
||||
result.interaktionen[i % width][i / width] = tiles.get(i).getInt("gid");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Gdx.app.error("Tiled LayerError", "Layer nicht gefundent");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,17 @@ public class EndlessMapProvider extends MapProvider {
|
||||
mapRightBoundary = appendMap(world, CRMapStorage.map_start, new Vector2(0, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNextEndlessMenu(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapProvider createNew() {
|
||||
EndlessMapProvider endlessMapProvider = new EndlessMapProvider(System.currentTimeMillis());
|
||||
return endlessMapProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(CRGameWorld world, Rectangle player)
|
||||
{
|
||||
|
@ -9,4 +9,8 @@ public abstract class MapProvider {
|
||||
public abstract void init(CRGameWorld world);
|
||||
|
||||
public abstract void update(CRGameWorld world, Rectangle player);
|
||||
|
||||
public abstract boolean isNextEndlessMenu();
|
||||
|
||||
public abstract MapProvider createNew();
|
||||
}
|
||||
|
@ -23,6 +23,17 @@ public class StaticMapProvider extends MapProvider {
|
||||
mapMaxWidth = map.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNextEndlessMenu(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapProvider createNew() {
|
||||
StaticMapProvider mapProvider = new StaticMapProvider(map);
|
||||
return mapProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(CRGameWorld world) {
|
||||
mapRightBoundary = appendMap(world);
|
||||
|
BIN
data/Tileset.pdn
BIN
data/Tileset.pdn
Binary file not shown.
BIN
data/Tileset.png
BIN
data/Tileset.png
Binary file not shown.
Before Width: | Height: | Size: 913 B After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in New Issue
Block a user