Added more blocks, updated Delta map

This commit is contained in:
Anuken
2017-05-20 10:08:25 -04:00
parent 6709d9856d
commit c74a8a2fa6
12 changed files with 214 additions and 116 deletions

View File

@@ -18,7 +18,7 @@ public class Vars{
public static final float respawnduration = 60*4;
public static final float wavespace = 20*60;
public static final float enemyspawnspace = 65;
public static boolean debug = false;
public static boolean debug = true;
public static final Vector2 vector = new Vector2();
@@ -35,7 +35,7 @@ public class Vars{
public static float breaktime = 0;
public static final String[] maps = {"delta", "canyon", "pit", "maze", "test"};
public static final String[] maps = {"delta", "canyon", "pit", "maze"};
public static Pixmap[] mapPixmaps;
public static Texture[] mapTextures;
public static int currentMap;

View File

@@ -25,7 +25,7 @@ public class World{
public static boolean solid(int x, int y){
Tile tile = tile(x, y);
return tile == null || tile.block().solid;
return tile == null || tile.block().solid || (tile.floor().solid && (tile.block() == Blocks.air));
}
public static int width(){

View File

@@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.utils.ObjectMap;
import io.anuke.mindustry.world.blocks.Blocks;
import io.anuke.ucore.graphics.Hue;
@@ -14,11 +15,18 @@ import io.anuke.ucore.noise.Noise;
import io.anuke.ucore.util.Mathf;
public class Generator{
static final int stonefloor = Color.rgba8888(Hue.rgb(54, 54, 54));
static final int stone = Color.rgba8888(Hue.rgb(128, 128, 128));
static final int spawn = Color.rgba8888(Color.RED);
static final int start = Color.rgba8888(Color.GREEN);
static ObjectMap<Integer, Block> colors = map(
Hue.rgb(80, 150, 90), Blocks.grass,
Hue.rgb(90, 180, 100), Blocks.grassblock,
Hue.rgb(80, 110, 180), Blocks.water,
Hue.rgb(70, 90, 150), Blocks.deepwater,
Hue.rgb(110, 80, 30), Blocks.dirt,
Hue.rgb(100, 100, 100), Blocks.stoneblock
);
/**Returns world size.*/
public static void generate(int map){
Pixmap pix = mapPixmaps[map];
@@ -31,37 +39,44 @@ public class Generator{
int color = pix.getPixel(x, pix.getHeight()-1-y);
if(Noise.nnoise(x, y, 8, 1) > 0.22){
floor = Blocks.iron;
}
if(Noise.nnoise(x, y, 8, 1) > 0.1){
floor = Blocks.grass;
}
if(Noise.nnoise(x, y, 8, 1) > 0.1){
floor = Blocks.water;
}
if(Mathf.chance(0.01)){
block = Blocks.rock;
}
if(Mathf.chance(0.01)){
block = Blocks.rock2;
}
if(Noise.nnoise(x, y, 6, 1) > 0.245){
floor = Blocks.coal;
}
if(color == stone && map == 1){
block = Blocks.dirtblock;
}else if(color == stone){
block = Mathf.choose(Blocks.stoneblock, Blocks.stoneblock2, Blocks.stoneblock3);
if(colors.containsKey(color)){
//TODO less hacky method
if(colors.get(color).name().contains("block")){
block = colors.get(color);
}else{
floor = colors.get(color);
}
}else if(color == start){
core = tiles[x][y];
}else if(color == spawn){
spawnpoints.add(tiles[x][y]);
}else{
if(Mathf.chance(0.02)){
block = Mathf.choose(Blocks.rock, Blocks.rock2);
}
}
if(floor == Blocks.stone || floor == Blocks.grass){
if(Noise.nnoise(x, y, 8, 1) > 0.2){
floor = Blocks.iron;
}
if(Noise.nnoise(x, y, 6, 1) > 0.242){
floor = Blocks.coal;
}
}
if(block == Blocks.grassblock){
floor = Blocks.grass;
block = Mathf.choose(Blocks.grassblock, Blocks.grassblock2);
}
if(block == Blocks.stoneblock){
block = Mathf.choose(Blocks.stoneblock, Blocks.stoneblock2, Blocks.stoneblock3);
}
if(floor == Blocks.grass && Mathf.chance(0.02) && block == Blocks.air){
block = Blocks.shrub;
}
tiles[x][y].setBlock(block);
@@ -80,4 +95,15 @@ public class Generator{
mapTextures[i] = new Texture(pix);
}
}
private static ObjectMap<Integer, Block> map(Object...objects){
ObjectMap<Integer, Block> out = new ObjectMap<>();
for(int i = 0; i < objects.length; i += 2){
out.put(Hue.rgb((Color)objects[i]), (Block)objects[i+1]);
}
return out;
}
}

View File

@@ -11,6 +11,16 @@ public class Blocks{
public void draw(Tile tile){}
},
deepwater = new Block("deepwater"){{
vary = false;
solid = true;
}},
water = new Block("water"){{
vary = false;
solid = true;
}},
stone = new Block("stone"),
dirt = new Block("dirt"),
@@ -21,11 +31,6 @@ public class Blocks{
grass = new Block("grass"),
water = new Block("water"){{
vary = false;
solid = true;
}},
stoneblock = new Block("stoneblock"){{
solid = true;
}},
@@ -38,16 +43,34 @@ public class Blocks{
solid = true;
}},
grassblock = new Block("grassblock"){{
solid = true;
}},
grassblock2 = new Block("grassblock2"){{
solid = true;
}},
mossblock = new Block("mossblock"){{
solid = true;
}},
shrub = new Block("shrub"){{
shadow = "shrubshadow";
breakable = true;
breaktime = 10;
}},
rock = new Block("rock"){{
shadow = "rockshadow";
breakable = true;
breaktime = 10;
breaktime = 15;
}},
rock2 = new Block("rock2"){{
shadow = "rock2shadow";
breakable = true;
breaktime = 10;
breaktime = 15;
}},
dirtblock = new Block("dirtblock"){{