MERGE CONFLICT

This commit is contained in:
Mike Schwörer 2017-04-14 01:26:54 +02:00
parent 283767a14b
commit 856f6e92e7
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
3 changed files with 57 additions and 46 deletions

View File

@ -1,10 +1,10 @@
package de.samdev.colorrunner.game.world;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Rectangle;
import java.util.ArrayList;
import java.util.List;
import de.samdev.colorrunner.game.world.entities.CRGameEntity;
import de.samdev.colorrunner.game.world.entities.gameentities.PlayerEntity;
import de.samdev.colorrunner.game.world.map.provider.MapProvider;
@ -47,7 +47,7 @@ public class CRGameWorld implements GameInputListener {
if(player.getPosition().y < - 10)
{
((Game) Gdx.app.getApplicationListener()).setScreen(new GameScreen());
//((Game) Gdx.app.getApplicationListener()).setScreen(new GameScreen());
}
mapprovider.update(this, player.bounds);

View File

@ -1,58 +1,63 @@
package de.samdev.colorrunner.game.world.map;
import com.badlogic.gdx.Gdx;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import com.badlogic.gdx.Gdx;
public class CRMapStorage {
public static final Random random = new Random();
public static final List<CRTiledMap> maps = new ArrayList<CRTiledMap>();
public static final CRTiledMap map_start = register("p00_start.tmx", false);
public static final CRTiledMap map_01 = register("p01.tmx");
public static final CRTiledMap map_02 = register("p02.tmx");
public static final CRTiledMap map_03 = register("p03.tmx");
public static final CRTiledMap map_04 = register("p04.tmx");
public static final CRTiledMap map_05 = register("p05.tmx");
public static final CRTiledMap map_06 = register("p06.tmx");
public static final CRTiledMap map_07 = register("p07.tmx");
public static final CRTiledMap map_08 = register("p08.tmx");
public static final CRTiledMap map_09 = register("p09.tmx");
public static final CRTiledMap map_10 = register("p10.tmx");
public static final CRTiledMap map_11 = register("p11.tmx");
public static final CRTiledMap map_12 = register("p12.tmx");
public static final CRTiledMap map_13 = register("p13.tmx");
public static final CRTiledMap map_14 = register("p14.tmx");
public static final CRTiledMap map_15 = register("p15.tmx");
public static final CRTiledMap map_16 = register("p16.tmx");
public static final CRTiledMap map_17 = register("p17.tmx");
public static final CRTiledMap map_18 = register("p18.tmx");
public static final CRTiledMap map_19 = register("p19.tmx");
public static final CRTiledMap map_20 = register("p20.tmx");
public static final CRTiledMap map_21 = register("p21.tmx");
public static final CRTiledMap map_22 = register("p22.tmx");
public static final CRTiledMap map_23 = register("p23.tmx");
public static final CRTiledMap map_24 = register("p24.tmx");
public static final CRTiledMap map_25 = register("p25.tmx");
public static final CRTiledMap map_26 = register("p26.tmx");
public static CRTiledMap register(String path) {
return register(path, true);
public static final CRTiledMap map_start = load("map_pieces", "p00_start.tmx");
public static final CRTiledMap map_01 = register("map_pieces", "p01.tmx");
public static final CRTiledMap map_02 = register("map_pieces", "p02.tmx");
public static final CRTiledMap map_03 = register("map_pieces", "p03.tmx");
public static final CRTiledMap map_04 = register("map_pieces", "p04.tmx");
public static final CRTiledMap map_05 = register("map_pieces", "p05.tmx");
public static final CRTiledMap map_06 = register("map_pieces", "p06.tmx");
public static final CRTiledMap map_07 = register("map_pieces", "p07.tmx");
public static final CRTiledMap map_08 = register("map_pieces", "p08.tmx");
public static final CRTiledMap map_09 = register("map_pieces", "p09.tmx");
public static final CRTiledMap map_10 = register("map_pieces", "p10.tmx");
public static final CRTiledMap map_11 = register("map_pieces", "p11.tmx");
public static final CRTiledMap map_12 = register("map_pieces", "p12.tmx");
public static final CRTiledMap map_13 = register("map_pieces", "p13.tmx");
public static final CRTiledMap map_14 = register("map_pieces", "p14.tmx");
public static final CRTiledMap map_15 = register("map_pieces", "p15.tmx");
public static final CRTiledMap map_16 = register("map_pieces", "p16.tmx");
public static final CRTiledMap map_17 = register("map_pieces", "p17.tmx");
public static final CRTiledMap map_18 = register("map_pieces", "p18.tmx");
public static final CRTiledMap map_19 = register("map_pieces", "p19.tmx");
public static final CRTiledMap map_20 = register("map_pieces", "p20.tmx");
public static final CRTiledMap map_21 = register("map_pieces", "p21.tmx");
public static final CRTiledMap map_22 = register("map_pieces", "p22.tmx");
public static final CRTiledMap map_23 = register("map_pieces", "p23.tmx");
public static final CRTiledMap map_24 = register("map_pieces", "p24.tmx");
public static final CRTiledMap map_25 = register("map_pieces", "p25.tmx");
public static final CRTiledMap map_26 = register("map_pieces", "p26.tmx");
public static final CRTiledMap lvl_01 = load("levels", "plevel001.tmx");
private static CRTiledMap load(String folder, String path) {
return internalload(folder, path, false);
}
public static CRTiledMap register(String path, boolean doRegister) {
CRTiledMap m = CRTiledMap.load(path, Gdx.files.internal("map_pieces/" + path).readString());
private static CRTiledMap register(String folder, String path) {
return internalload(folder, path, true);
}
private static CRTiledMap internalload(String folder, String path, boolean doRegister) {
CRTiledMap m = CRTiledMap.load(path, Gdx.files.internal(folder + "/" + path).readString());
if (doRegister)
maps.add(m);
return m;
}
public static CRTiledMap getMap() {
return maps.get(random.nextInt(maps.size()));
public static CRTiledMap getMap(Random r) {
return maps.get(r.nextInt(maps.size()));
}
}

View File

@ -5,6 +5,7 @@ import com.badlogic.gdx.math.Vector2;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import de.samdev.colorrunner.game.renderer.AbstractGameRenderer;
import de.samdev.colorrunner.game.world.CRGameWorld;
@ -15,10 +16,15 @@ import de.samdev.colorrunner.game.world.map.CRTiledMap;
import de.samdev.colorrunner.game.world.map.MapSection;
public class EndlessMapProvider extends MapProvider {
private final Random random;
public List<MapSection> sections;
private float mapRightBoundary = 0;
public EndlessMapProvider(long seed) {
random = new Random(seed);
}
@Override
public void init(CRGameWorld world) {
sections = new ArrayList<MapSection>();
@ -29,7 +35,7 @@ public class EndlessMapProvider extends MapProvider {
public void update(CRGameWorld world, Rectangle player)
{
while (player.x + AbstractGameRenderer.MAX_GAME_WIDTH*2 > mapRightBoundary) {
float width = appendMap(world, CRMapStorage.getMap(), new Vector2(mapRightBoundary, 0));
float width = appendMap(world, CRMapStorage.getMap(random), new Vector2(mapRightBoundary, 0));
mapRightBoundary += width;
}
}