Skip to content

Commit

Permalink
revised noise functions and level gen
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisj42 committed Jul 18, 2018
1 parent 071135a commit 8ca7cdd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 20 deletions.
2 changes: 1 addition & 1 deletion core/client/src/miniventure/game/client/LevelViewport.java
Expand Up @@ -147,7 +147,7 @@ public void render(@NotNull Vector2 cameraCenter, Color ambientLighting, @NotNul
batch.end();
}

private void zoom(int dir) {
public void zoom(int dir) {
zoom += dir;
zoom = MathUtils.clamp(zoom, MIN_ZOOM, MAX_ZOOM);
resetCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
Expand Down
12 changes: 4 additions & 8 deletions core/client/src/miniventure/game/screen/MainMenu.java
Expand Up @@ -40,7 +40,7 @@ public class MainMenu extends MenuScreen {
private final Color lightOverlay;
private final Vector2 cameraPos, cameraDir;

private static final float PAN_SPEED = 3f; // in tiles/second.
private static final float PAN_SPEED = 4.5f; // in tiles/second.

public MainMenu() {
super();
Expand Down Expand Up @@ -107,10 +107,11 @@ public void clicked(InputEvent e, float x, float y) {
// setup level scrolling in background

levelView = new LevelViewport();
levelView.zoom(-1);
TimeOfDay time = TimeOfDay.values[MathUtils.random(TimeOfDay.values.length-1)];
lightOverlay = TimeOfDay.getSkyColor(time.getStartOffsetSeconds());

LevelGenerator generator = new LevelGenerator(MathUtils.random.nextLong(), 30, 20); // 100, 60
LevelGenerator generator = new LevelGenerator(MathUtils.random.nextLong(), 200, 100);
backgroundLevel = new DisplayLevel(generator);

Vector2 size = new Vector2(levelView.getViewWidth(), levelView.getViewHeight());//.scl(0.5f);
Expand All @@ -120,12 +121,6 @@ public void clicked(InputEvent e, float x, float y) {

// setup background music
Music song = ClientCore.setMusicTrack(Gdx.files.internal("audio/music/title.mp3"));
/*song.setOnCompletionListener(music -> MyUtils.delay(MathUtils.random(5000, 10000), () -> {
music.stop();
music.play();
}));*/
//song.setVolume(0.5f);
//MyUtils.delay(100, song::play);
song.setLooping(true);
song.play();
}
Expand All @@ -135,6 +130,7 @@ public void clicked(InputEvent e, float x, float y) {

@Override
public void draw() {
// levelView.handleInput();
levelView.render(cameraPos, lightOverlay, backgroundLevel);

cameraPos.add(cameraDir.cpy().scl(GameCore.getDeltaTime()));
Expand Down
2 changes: 1 addition & 1 deletion core/game/src/miniventure/game/GameCore.java
Expand Up @@ -33,7 +33,7 @@

public class GameCore {

public static final Version VERSION = new Version("1.5.4.dev");
public static final Version VERSION = new Version("1.5.4");

public static final int DEFAULT_SCREEN_WIDTH = 800;
public static final int DEFAULT_SCREEN_HEIGHT = 450;
Expand Down
Expand Up @@ -59,13 +59,6 @@ public TileTypeEnum getTileType(int x, int y) {
else
System.out.println("multimatch for value "+values[i]+"; first region="+biome+", second region="+regions[i+1]+" sticking with first match.");
}
/*else if(val <= regions[i].getSize()+threshold) {
// in range for canceling other biomes, but not quite enough to be this biome
if(biome != null)
return filler.getTileType(x, y); // previous found biome is too close
close = true; // for checking future biomes
}*/
}

if(biome == null) biome = filler; // no biomes were in range.
Expand Down
Expand Up @@ -206,7 +206,6 @@ private static NoiseMapper DEFAULT_MAPPER() {

private static NoiseMapper ISLAND_MAPPER() {
NamedNoiseFunction continentNoise = new NamedNoiseFunction("Continent Noise", 500, 2);
NamedNoiseFunction landNoise = new NamedNoiseFunction("Land Noise", 300, 3);
NamedNoiseFunction biomeNoise = new NamedNoiseFunction("Biome Noise", 120, 2);
NamedNoiseFunction detailNoise = new NamedNoiseFunction("Detail Noise", 12, 2);
NamedNoiseFunction islandNoise = new NamedNoiseFunction("Island Noise", 24, 2);
Expand All @@ -215,7 +214,7 @@ private static NoiseMapper ISLAND_MAPPER() {

NoiseMapper plainsBiome = new NoiseMapper("Plains", detailNoise)
.addRegion(GRASS, 4)
.addRegion(WATER, .07f)
// .addRegion(WATER, 1f)
.addRegion(GRASS, 3)
.addRegion(TREE_CARTOON, 1);

Expand All @@ -239,7 +238,7 @@ private static NoiseMapper ISLAND_MAPPER() {
NoiseMapper snowBiome = new NoiseMapper("Snow", biomeNoise)
.addRegion(SNOW, 1)
.addRegion(GRASS, .25f)
.addRegion(WATER, .07f)
// .addRegion(WATER, .1f)
.addRegion(SNOW, 1);

/*NoiseMapper volcanoBiome = new NoiseMapper("Volcano", continentNoise)
Expand Down

0 comments on commit 8ca7cdd

Please sign in to comment.