From 856f6e92e731a99cf1ddfb1c964d5de4bb86fc0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Fri, 14 Apr 2017 01:26:54 +0200 Subject: [PATCH] MERGE CONFLICT --- .../colorrunner/game/world/CRGameWorld.java | 6 +- .../game/world/map/CRMapStorage.java | 89 ++++++++++--------- .../map/provider/EndlessMapProvider.java | 8 +- 3 files changed, 57 insertions(+), 46 deletions(-) diff --git a/core/src/de/samdev/colorrunner/game/world/CRGameWorld.java b/core/src/de/samdev/colorrunner/game/world/CRGameWorld.java index e504295..8bc75f6 100644 --- a/core/src/de/samdev/colorrunner/game/world/CRGameWorld.java +++ b/core/src/de/samdev/colorrunner/game/world/CRGameWorld.java @@ -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); diff --git a/core/src/de/samdev/colorrunner/game/world/map/CRMapStorage.java b/core/src/de/samdev/colorrunner/game/world/map/CRMapStorage.java index 1e246ab..ed0c0a1 100644 --- a/core/src/de/samdev/colorrunner/game/world/map/CRMapStorage.java +++ b/core/src/de/samdev/colorrunner/game/world/map/CRMapStorage.java @@ -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 maps = new ArrayList(); - 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())); } } diff --git a/core/src/de/samdev/colorrunner/game/world/map/provider/EndlessMapProvider.java b/core/src/de/samdev/colorrunner/game/world/map/provider/EndlessMapProvider.java index 5e631e6..a257bd1 100644 --- a/core/src/de/samdev/colorrunner/game/world/map/provider/EndlessMapProvider.java +++ b/core/src/de/samdev/colorrunner/game/world/map/provider/EndlessMapProvider.java @@ -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 sections; private float mapRightBoundary = 0; + public EndlessMapProvider(long seed) { + random = new Random(seed); + } + @Override public void init(CRGameWorld world) { sections = new ArrayList(); @@ -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; } }