New blocks

This commit is contained in:
Anuken
2019-01-27 23:26:07 -05:00
parent db2e6b6973
commit e9a82652a0
44 changed files with 1800 additions and 1838 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 126 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 109 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 154 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 817 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 124 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 126 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 136 B

Binary file not shown.
+44
View File
@@ -0,0 +1,44 @@
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
#define SPACE 2.0
uniform sampler2D u_texture;
uniform vec4 u_color;
uniform vec2 u_texsize;
uniform float u_scl;
varying vec4 v_color;
varying vec2 v_texCoord;
void main() {
vec2 v = vec2(1.0/u_texsize.x, 1.0/u_texsize.y);
vec4 c = texture2D(u_texture, v_texCoord.xy);
float spacing = SPACE * u_scl;
gl_FragColor = mix(vec4(0.0, 0.0, 0.0, min(c.a, u_color.a)), u_color,
(1.0-step(0.001, texture2D(u_texture, v_texCoord.xy).a)) *
step(0.001,
//cardinals
texture2D(u_texture, v_texCoord.xy + vec2(0, spacing) * v).a +
texture2D(u_texture, v_texCoord.xy + vec2(0, -spacing) * v).a +
texture2D(u_texture, v_texCoord.xy + vec2(spacing, 0) * v).a +
texture2D(u_texture, v_texCoord.xy + vec2(-spacing, 0) * v).a +
//cardinal edges
texture2D(u_texture, v_texCoord.xy + vec2(spacing, spacing) * v).a +
texture2D(u_texture, v_texCoord.xy + vec2(spacing, -spacing) * v).a +
texture2D(u_texture, v_texCoord.xy + vec2(-spacing, spacing) * v).a +
texture2D(u_texture, v_texCoord.xy + vec2(-spacing, -spacing) * v).a +
//cardinals * 2
texture2D(u_texture, v_texCoord.xy + vec2(0, spacing) * v*2.0).a +
texture2D(u_texture, v_texCoord.xy + vec2(0, -spacing) * v*2.0).a +
texture2D(u_texture, v_texCoord.xy + vec2(spacing, 0) * v*2.0).a +
texture2D(u_texture, v_texCoord.xy + vec2(-spacing, 0) * v*2.0).a
));
}
File diff suppressed because it is too large Load Diff
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1020 KiB

After

Width:  |  Height:  |  Size: 1013 KiB

+21 -14
View File
@@ -32,8 +32,8 @@ public class Blocks implements ContentList{
public static Block
//environment
air, part, spawn, space, metalfloor, deepwater, water, tar, stone, craters, charr, blackstone, dirt, sand, ice, snow,
grass, shrub, rock, icerock, blackrock, rocks, cliffs, pine, whiteTree,
air, part, spawn, space, metalfloor, deepwater, water, tar, stone, craters, charr, blackstone, dirt, sand, ice, snow, iceSnow,
grass, holostone, holostoneSnow, shrub, rock, icerock, blackrock, rocks, icerocks, cliffs, pine, whiteTree, sporeCluster,
//crafting
siliconSmelter, graphitePress, plastaniumCompressor, multiPress, phaseWeaver, surgeSmelter, pyratiteMixer, blastMixer, cryofluidMixer,
@@ -182,12 +182,15 @@ public class Blocks implements ContentList{
dragMultiplier = 0.2f;
speedMultiplier = 0.4f;
minimapColor = Color.valueOf("b8eef8");
hasOres = true;
}};
snow = new Floor("snow"){{
minimapColor = Color.valueOf("c2d1d2");
hasOres = true;
}};
iceSnow = new Floor("ice-snow"){{
minimapColor = Color.valueOf("c2d1d2");
variants = 3;
}};
grass = new Floor("grass"){{
@@ -197,24 +200,16 @@ public class Blocks implements ContentList{
shrub = new Rock("shrub");
rock = new Rock("rock"){{
variants = 2;
}};
cliffs = new StaticWall("cliffs"){{
variants = 1;
fillsTile = false;
}};
icerock = new Rock("icerock"){{
rocks = new StaticWall("rocks"){{
variants = 2;
}};
blackrock = new Rock("blackrock"){{
variants = 1;
}};
rocks = new StaticWall("rocks"){{
icerocks = new StaticWall("icerocks"){{
variants = 2;
}};
@@ -226,6 +221,18 @@ public class Blocks implements ContentList{
whiteTree = new TreeBlock("white-tree-dead"){{
}};
sporeCluster = new Rock("spore-cluster"){{
variants = 3;
}};
holostone = new Floor("holostone"){{
hasOres = true;
}};
holostoneSnow = new Floor("holostone-snow"){{
}};
//endregion
//region crafting
@@ -5,6 +5,7 @@ import io.anuke.mindustry.game.ContentList;
import io.anuke.mindustry.game.Rules;
import io.anuke.mindustry.game.SpawnGroup;
import io.anuke.mindustry.maps.generators.MapGenerator;
import io.anuke.mindustry.maps.generators.MapGenerator.Decoration;
import io.anuke.mindustry.type.ItemStack;
import io.anuke.mindustry.type.Zone;
import io.anuke.mindustry.world.Block;
@@ -58,7 +59,7 @@ public class Zones implements ContentList{
}};
}};
craters = new Zone("craters", new MapGenerator("craters", 1){{ distortion = 0; }}){{
craters = new Zone("craters", new MapGenerator("craters", 1).dist(0)){{
deployCost = ItemStack.with(Items.copper, 300);
startingItems = ItemStack.with(Items.copper, 200);
conditionWave = 15;
@@ -106,7 +107,8 @@ public class Zones implements ContentList{
}};
}};
frozenForest = new Zone("frozenForest", new MapGenerator("frozenForest")){{ //TODO implement
frozenForest = new Zone("frozenForest", new MapGenerator("frozenForest")
.decor(new Decoration(Blocks.snow, Blocks.sporeCluster, 0.05))){{
alwaysUnlocked = true;
deployCost = ItemStack.with(Items.copper, 300);
startingItems = ItemStack.with(Items.copper, 200);
@@ -172,6 +172,11 @@ public class Renderer implements ApplicationListener{
blocks.processBlocks();
blocks.drawShadows();
blocks.floor.beginDraw();
blocks.floor.drawLayer(CacheLayer.walls);
blocks.floor.endDraw();
blocks.drawBlocks(Layer.block);
blocks.drawFog();
@@ -134,17 +134,21 @@ public class MapRenderer implements Disposable{
mesh.draw(idxWall, region, wx * tilesize, wy * tilesize, 8, 8);
}
float offsetX = -(wall.size/3)*tilesize, offsetY = -(wall.size/3) * tilesize;
if(wall.update || wall.destructible){
mesh.setColor(team.color);
region = Core.atlas.find("block-border");
}else if(!wall.synthetic() && bw != 0){
region = wall.icon(Icon.full) == Core.atlas.find("____") ? Core.atlas.find("clear") : wall.icon(Icon.full);
offsetX = tilesize/2f - region.getWidth()/2f * Draw.scl;
offsetY = tilesize/2f - region.getHeight()/2f * Draw.scl;
}else{
region = Core.atlas.find("clear");
}
mesh.draw(idxDecal, region,
wx * tilesize - (wall.size/3) * tilesize, wy * tilesize - (wall.size/3) * tilesize,
wx * tilesize + offsetX, wy * tilesize + offsetY,
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl);
mesh.setColor(Color.WHITE);
}
@@ -100,18 +100,21 @@ public class BlockRenderer{
public void drawShadows(){
if(disableShadows) return;
Draw.color();
if(!Core.graphics.isHidden() && (shadows.getWidth() != Core.graphics.getWidth() || shadows.getHeight() != Core.graphics.getHeight())){
shadows.resize(Core.graphics.getWidth(), Core.graphics.getHeight());
}
Tmp.tr1.set(shadows.getTexture());
Shaders.outline.color.set(shadowColor);
Shaders.outline.scl = renderer.cameraScale()/3f;
Shaders.outline.region = Tmp.tr1;
Shaders.shadow.color.set(shadowColor);
Shaders.shadow.scl = renderer.cameraScale()/3f;
Shaders.shadow.region = Tmp.tr1;
Draw.flush();
shadows.begin();
Core.graphics.clear(Color.CLEAR);
floor.beginDraw();
floor.drawLayer(CacheLayer.walls);
floor.endDraw();
@@ -127,7 +130,7 @@ public class BlockRenderer{
Draw.flush();
shadows.end();
Draw.shader(Shaders.outline);
Draw.shader(Shaders.shadow);
Draw.rect(Draw.wrap(shadows.getTexture()),
camera.position.x,
camera.position.y,
@@ -188,10 +191,6 @@ public class BlockRenderer{
lastCamY = avgy;
lastRangeX = rangex;
lastRangeY = rangey;
floor.beginDraw();
floor.drawLayer(CacheLayer.walls);
floor.endDraw();
}
public void drawBlocks(Layer stopAt){
@@ -206,9 +205,7 @@ public class BlockRenderer{
Block block = req.tile.block();
if(req.layer == Layer.shadow){
Draw.color(0f, 0f, 0f, 0.45f);
block.drawShadow(req.tile);
Draw.color();
}else if(req.layer == Layer.block){
block.draw(req.tile);
if(block.synthetic() && req.tile.getTeam() != players[0].getTeam()){
@@ -12,6 +12,7 @@ import static io.anuke.mindustry.Vars.world;
public class Shaders{
public static Outline outline;
public static Shadow shadow;
public static BlockBuild blockbuild;
public static BlockPreview blockpreview;
public static Shield shield;
@@ -27,6 +28,7 @@ public class Shaders{
public static void init(){
outline = new Outline();
shadow = new Shadow();
blockbuild = new BlockBuild();
blockpreview = new BlockPreview();
shield = new Shield();
@@ -130,6 +132,23 @@ public class Shaders{
}
}
public static class Shadow extends LoadShader{
public Color color = new Color();
public TextureRegion region = new TextureRegion();
public float scl;
public Shadow(){
super("shadow", "default");
}
@Override
public void apply(){
setUniformf("u_color", color);
setUniformf("u_scl", scl);
setUniformf("u_texsize", region.getTexture().getWidth(), region.getTexture().getHeight());
}
}
public static class BlockBuild extends LoadShader{
public Color color = new Color();
public float progress;
@@ -10,6 +10,7 @@ import io.anuke.mindustry.io.MapIO;
import io.anuke.mindustry.maps.Map;
import io.anuke.mindustry.maps.MapTileData;
import io.anuke.mindustry.maps.MapTileData.TileDataMarker;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.OreBlock;
import io.anuke.mindustry.world.blocks.storage.CoreBlock;
@@ -19,10 +20,9 @@ import static io.anuke.mindustry.Vars.*;
public class MapGenerator extends Generator{
private Map map;
private String mapName;
private Array<Decoration> decorations = new Array<>();
/**How much the landscape is randomly distorted.*/
public float distortion = 3;
/**The amount of final enemy spawns used. -1 to use everything in the map.
* This amount of enemy spawns is selected randomly from the map.*/
public int enemySpawns = -1;
@@ -36,6 +36,16 @@ public class MapGenerator extends Generator{
this.enemySpawns = enemySpawns;
}
public MapGenerator decor(Decoration... decor){
this.decorations = Array.with(decor);
return this;
}
public MapGenerator dist(float distortion){
this.distortion = distortion;
return this;
}
@Override
public void init(){
map = world.maps.loadInternalMap(mapName);
@@ -75,10 +85,18 @@ public class MapGenerator extends Generator{
for(int x = 0; x < data.width(); x++){
for(int y = 0; y < data.height(); y++){
final double scl = 10;
Tile tile = tiles[x][y];
int newX = Mathf.clamp((int)(simplex.octaveNoise2D(1, 1, 1.0 / scl, x, y) * distortion + x), 0, data.width()-1);
int newY = Mathf.clamp((int)(simplex.octaveNoise2D(1, 1, 1.0 / scl, x + 9999, y + 9999) * distortion + y), 0, data.height()-1);
if(tiles[newX][newY].block() != Blocks.spawn && !tiles[x][y].block().synthetic()&& !tiles[newX][newY].block().synthetic()){
tiles[x][y].setBlock(tiles[newX][newY].block());
if(tiles[newX][newY].block() != Blocks.spawn && !tile.block().synthetic()&& !tiles[newX][newY].block().synthetic()){
tile.setBlock(tiles[newX][newY].block());
}
for(Decoration decor : decorations){
if(tile.block() == Blocks.air && tile.floor() == decor.floor && Mathf.chance(decor.chance)){
tile.setBlock(decor.wall);
}
}
}
}
@@ -122,4 +140,16 @@ public class MapGenerator extends Generator{
world.prepareTiles(tiles);
world.setMap(map);
}
public static class Decoration{
public final Block floor;
public final Block wall;
public final double chance;
public Decoration(Block floor, Block wall, double chance){
this.floor = floor;
this.wall = wall;
this.chance = chance;
}
}
}
@@ -19,13 +19,11 @@ public class Rock extends Block{
@Override
public void draw(Tile tile){
Draw.colorl(1f - tile.getRotation() / 4f);
if(variants > 0){
Draw.rect(regions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, regions.length - 1))], tile.worldx(), tile.worldy());
}else{
Draw.rect(region, tile.worldx(), tile.worldy());
}
Draw.color();
}
@Override
@@ -23,14 +23,11 @@ public class StaticWall extends Rock{
@Override
public void draw(Tile tile){
//Draw.colorl(1f - tile.getRotation() / 4f);
int rx = tile.x / 2 * 2;
int ry = tile.y / 2 * 2;
if(Core.atlas.isFound(large) && eq(rx, ry) && Mathf.randomSeed(Pos.get(rx, ry)) < 0.5){
if(rx == tile.x && ry == tile.y){
//Draw.colorl(1f - avg(rx, ry) / 4f);
Draw.rect(large, tile.worldx() + tilesize/2f, tile.worldy() + tilesize/2f);
}
}else if(variants > 0){
@@ -38,7 +35,6 @@ public class StaticWall extends Rock{
}else{
Draw.rect(region, tile.worldx(), tile.worldy());
}
// Draw.color();
}
@Override
@@ -1,12 +1,13 @@
package io.anuke.mindustry.world.blocks;
import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.math.Mathf;
import io.anuke.mindustry.graphics.Layer;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
public class TreeBlock extends Block{
static final float shadowOffset = 5f;
static final float shadowOffset = 10f;
public TreeBlock(String name){
super(name);
@@ -15,13 +16,17 @@ public class TreeBlock extends Block{
expanded = true;
}
@Override
public void draw(Tile tile){}
@Override
public void drawShadow(Tile tile){
Draw.rect(region, tile.drawx() - shadowOffset, tile.drawy() - shadowOffset);
Draw.rect(region, tile.drawx(), tile.drawy(), Mathf.randomSeed(tile.pos(), 0, 4) * 90);
Draw.rect(region, tile.drawx() - shadowOffset, tile.drawy() - shadowOffset, Mathf.randomSeed(tile.pos(), 0, 4) * 90);
}
@Override
public void drawLayer(Tile tile){
Draw.rect(region, tile.drawx(), tile.drawy());
Draw.rect(region, tile.drawx(), tile.drawy(), Mathf.randomSeed(tile.pos(), 0, 4) * 90);
}
}
+2
View File
@@ -15,6 +15,7 @@ def antialias = {File file ->
def image = ImageIO.read(file)
def out = ImageIO.read(file)
def getRGB = { int ix, int iy ->
//if(ix <= 0 || iy <= 0 || ix >= image.width || iy >= image.height) return 0
return image.getRGB(Math.max(Math.min(ix, image.width - 1), 0), Math.max(Math.min(iy, image.height - 1), 0))
}
@@ -112,6 +113,7 @@ task scaleSprites4x(){
def scaled = new BufferedImage(image.getWidth() * 2, image.getHeight() * 2, BufferedImage.TYPE_INT_ARGB)
def getRGB = { int ix, int iy ->
//if(ix <= 0 || iy <= 0 || ix >= image.width || iy >= image.height) return 0
return image.getRGB(Math.max(Math.min(ix, image.width - 1), 0), Math.max(Math.min(iy, image.height - 1), 0))
}