diff --git a/core/src/io/anuke/mindustry/content/blocks/Blocks.java b/core/src/io/anuke/mindustry/content/blocks/Blocks.java index 1df5b8ab24..0b38edf83f 100644 --- a/core/src/io/anuke/mindustry/content/blocks/Blocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/Blocks.java @@ -96,6 +96,7 @@ public class Blocks extends BlockList implements ContentList{ }}; stone = new Floor("stone") {{ + hasOres = true; drops = new ItemStack(Items.stone, 1); blends = block -> block != this && !(block instanceof Ore); }}; diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index 3a8f0bbdf4..81eb23257c 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -151,7 +151,7 @@ public class Control extends Module{ hiscore = false; - ui.hudfrag.fadeRespawn(false); + saves.resetSave(); }); Events.on(WaveEvent.class, () -> { @@ -260,7 +260,6 @@ public class Control extends Module{ public void playMap(Map map){ ui.loadfrag.show(); - saves.resetSave(); Timers.run(5f, () -> { threads.run(() -> { diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index 216b744551..bcd2e48137 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -298,14 +298,16 @@ public class Renderer extends RendererModule{ .lerp(tmpVector2.set(lastx, lasty), alpha); s.setRotation(Mathf.slerp(s.lastPosition().z, lastrot, alpha)); - s.set(tmpVector1.x, tmpVector1.y); + s.setX(tmpVector1.x); + s.setY(tmpVector1.y); } } drawer.accept(t); if(threads.doInterpolate() && threads.isEnabled()) { - t.set(lastx, lasty); + t.setX(lastx); + t.setY(lasty); if (t instanceof SolidTrait) { ((SolidTrait) t).setRotation(lastrot); diff --git a/core/src/io/anuke/mindustry/graphics/FloorRenderer.java b/core/src/io/anuke/mindustry/graphics/FloorRenderer.java index 951eba6220..8ee8300121 100644 --- a/core/src/io/anuke/mindustry/graphics/FloorRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/FloorRenderer.java @@ -220,7 +220,7 @@ public class FloorRenderer { Timers.mark(); - int chunksx = world.width() / chunksize, chunksy = world.height() / chunksize; + int chunksx = Mathf.ceil((float)world.width() / chunksize), chunksy = Mathf.ceil((float)world.height() / chunksize); cache = new Chunk[chunksx][chunksy]; cbatch = new CacheBatch(world.width()*world.height()*4*4); diff --git a/core/src/io/anuke/mindustry/graphics/MinimapRenderer.java b/core/src/io/anuke/mindustry/graphics/MinimapRenderer.java index d438783577..af990b8ece 100644 --- a/core/src/io/anuke/mindustry/graphics/MinimapRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/MinimapRenderer.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.graphics; import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.Pixmap.Format; import com.badlogic.gdx.graphics.Texture; @@ -34,6 +35,7 @@ public class MinimapRenderer implements Disposable{ private TextureRegion region; private Rectangle rect = new Rectangle(); private Rectangle clipRect = new Rectangle(); + private Color tmpColor = new Color(); private int zoom = 4; public MinimapRenderer(){ @@ -138,6 +140,11 @@ public class MinimapRenderer implements Disposable{ private int colorFor(Tile tile){ int color = tile.breakable() ? tile.target().getTeam().intColor : ColorMapper.getColor(tile.block()); if(color == 0) color = ColorMapper.getColor(tile.floor()); + if(tile.cliffs != 0){ + tmpColor.set(color); + tmpColor.mul(1.5f, 1.5f, 1.5f, 1f); + color = Color.rgba8888(tmpColor); + } return color; } diff --git a/core/src/io/anuke/mindustry/io/MapIO.java b/core/src/io/anuke/mindustry/io/MapIO.java index a6e7268e63..55c560e520 100644 --- a/core/src/io/anuke/mindustry/io/MapIO.java +++ b/core/src/io/anuke/mindustry/io/MapIO.java @@ -35,6 +35,7 @@ public class MapIO { data.position(0, 0); TileDataMarker marker = data.newDataMarker(); + Color color = new Color(); for(int y = 0; y < data.height(); y ++){ for(int x = 0; x < data.width(); x ++){ @@ -43,7 +44,14 @@ public class MapIO { Block wall = Block.getByID(marker.wall); int wallc = ColorMapper.getColor(wall); if(wallc == 0 && (wall.update || wall.solid || wall.breakable)) wallc = Color.rgba8888(Team.values()[marker.team].color); - pixmap.drawPixel(x, pixmap.getHeight() - 1 - y, wallc == 0 ? ColorMapper.getColor(floor) : wallc); + wallc = wallc == 0 ? ColorMapper.getColor(floor) : wallc; + if(marker.elevation > 0){ + float scaling = 1f + marker.elevation/8f; + color.set(wallc); + color.mul(scaling, scaling, scaling, 1f); + wallc = Color.rgba8888(color); + } + pixmap.drawPixel(x, pixmap.getHeight() - 1 - y, wallc); } } diff --git a/core/src/io/anuke/mindustry/ui/dialogs/LevelDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/LevelDialog.java index a4a9ebdb6f..e7c6e38abb 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/LevelDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/LevelDialog.java @@ -1,11 +1,20 @@ package io.anuke.mindustry.ui.dialogs; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.utils.ObjectMap; import io.anuke.mindustry.game.Difficulty; import io.anuke.mindustry.game.GameMode; import io.anuke.mindustry.io.Map; +import io.anuke.mindustry.io.MapMeta; +import io.anuke.mindustry.io.MapTileData; +import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.WorldGenerator; +import io.anuke.mindustry.world.mapgen.ProcGen; import io.anuke.ucore.core.Settings; +import io.anuke.ucore.core.Timers; +import io.anuke.ucore.entities.EntityPhysics; import io.anuke.ucore.scene.event.Touchable; import io.anuke.ucore.scene.ui.*; import io.anuke.ucore.scene.ui.layout.Stack; @@ -99,7 +108,6 @@ public class LevelDialog extends FloatingDialog{ ImageButton image = new ImageButton(new TextureRegion(map.texture), "togglemap"); image.row(); image.add(inset).width(images+6); - //TODO custom map delete button image.clicked(() -> { hide(); @@ -112,10 +120,41 @@ public class LevelDialog extends FloatingDialog{ maps.add(stack).width(170).top().pad(4f); - maps.marginRight(26); - i ++; } + + maps.addImageButton("icon-editor", 16*4, () -> { + hide(); + + ProcGen gen = new ProcGen(); + MapTileData data = gen.generate(null); + Map map = new Map("generated-map", new MapMeta(0, new ObjectMap<>(), data.width(), data.height(), null), true, () -> null); + + ui.loadfrag.show(); + + Timers.run(5f, () -> { + threads.run(() -> { + logic.reset(); + + world.beginMapLoad(); + world.setMap(map); + + int width = map.meta.width, height = map.meta.height; + + Tile[][] tiles = world.createTiles(data.width(), data.height()); + + EntityPhysics.resizeTree(0, 0, width * tilesize, height * tilesize); + + WorldGenerator.generate(tiles, data, true, 0); + + world.endMapLoad(); + + logic.play(); + + Gdx.app.postRunnable(ui.loadfrag::hide); + }); + }); + }).size(170, 154f + 73).pad(4f); content().add(pane).uniformX(); } diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index cd90bd5b7a..632626a587 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -343,8 +343,4 @@ public class HudFragment implements Fragment{ l.setTouchable(!paused ? Touchable.enabled : Touchable.disabled); }); } - - public void fadeRespawn(boolean in){ - //respawntable.addAction(Actions.color(in ? new Color(0, 0, 0, 0.3f) : Color.CLEAR, 0.3f)); - } } diff --git a/core/src/io/anuke/mindustry/world/blocks/Floor.java b/core/src/io/anuke/mindustry/world/blocks/Floor.java index abc5ecddfd..21671cec59 100644 --- a/core/src/io/anuke/mindustry/world/blocks/Floor.java +++ b/core/src/io/anuke/mindustry/world/blocks/Floor.java @@ -58,7 +58,7 @@ public class Floor extends Block{ /**liquids that drop from this block, used for pumps*/ public Liquid liquidDrop = null; /**Whether ores generate on this block.*/ - public boolean hasOres = true; + public boolean hasOres = false; /**whether this block can be drowned in*/ public boolean isLiquid; diff --git a/core/src/io/anuke/mindustry/world/mapgen/ProcGen.java b/core/src/io/anuke/mindustry/world/mapgen/ProcGen.java index 2c76069821..3b5ce7bc5c 100644 --- a/core/src/io/anuke/mindustry/world/mapgen/ProcGen.java +++ b/core/src/io/anuke/mindustry/world/mapgen/ProcGen.java @@ -1,20 +1,49 @@ package io.anuke.mindustry.world.mapgen; +import io.anuke.mindustry.content.blocks.Blocks; +import io.anuke.mindustry.content.blocks.StorageBlocks; +import io.anuke.mindustry.game.Team; import io.anuke.mindustry.io.MapTileData; +import io.anuke.mindustry.io.MapTileData.DataPosition; +import io.anuke.mindustry.io.MapTileData.TileDataMarker; import io.anuke.ucore.noise.RidgedPerlin; import io.anuke.ucore.noise.Simplex; +import io.anuke.ucore.util.Bits; +import io.anuke.ucore.util.Mathf; public class ProcGen { public RidgedPerlin rid = new RidgedPerlin(1, 1); public Simplex sim = new Simplex(); public MapTileData generate(GenProperties props){ + sim.setSeed(Mathf.random(9999)); + rid = new RidgedPerlin(Mathf.random(9999), 1); + MapTileData data = new MapTileData(300, 300); + TileDataMarker marker = data.newDataMarker(); for (int x = 0; x < data.width(); x++) { for (int y = 0; y < data.height(); y++) { + marker.floor = (byte)Blocks.stone.id; + double r = rid.getValue(x, y, 1/70f); + double elevation = sim.octaveNoise2D(3, 0.6, 1f/50, x, y) * 3 - 1 - r*2; + + if(r > 0.0){ + marker.floor = (byte)Blocks.water.id; + elevation = 0; + + if(r > 0.055){ + marker.floor = (byte)Blocks.deepwater.id; + } + } + + marker.elevation = (byte)Math.max(elevation, 0); + + data.write(marker); } } - return null; + data.write(data.width()/2, data.height()/2, DataPosition.wall, (byte)StorageBlocks.core.id); + data.write(data.width()/2, data.height()/2, DataPosition.rotationTeam, Bits.packByte((byte)0, (byte)Team.blue.ordinal())); + return data; } }