1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-09-17 11:27:35 +03:00

Better cliff sprites

This commit is contained in:
Anuken 2020-10-10 11:37:58 -04:00
parent 5a31d419fc
commit fb831e8fef
29 changed files with 4225 additions and 429 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 435 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 B

After

Width:  |  Height:  |  Size: 389 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 239 B

After

Width:  |  Height:  |  Size: 377 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 562 KiB

After

Width:  |  Height:  |  Size: 562 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 KiB

After

Width:  |  Height:  |  Size: 372 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 KiB

After

Width:  |  Height:  |  Size: 429 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 MiB

After

Width:  |  Height:  |  Size: 2.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 KiB

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 331 KiB

After

Width:  |  Height:  |  Size: 354 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 KiB

After

Width:  |  Height:  |  Size: 426 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@ -65,6 +65,11 @@ public class World{
return tile == null || tile.block().solid;
}
public boolean wallSolidFull(int x, int y){
Tile tile = tile(x, y);
return tile == null || (tile.block().solid && tile.block().fillsTile);
}
public boolean isAccessible(int x, int y){
return !wallSolid(x, y - 1) || !wallSolid(x, y + 1) || !wallSolid(x - 1, y) || !wallSolid(x + 1, y);
}

View File

@ -557,6 +557,12 @@ public class MapEditorDialog extends Dialog implements Disposable{
t.add(slider).width(size * 3f - 20).padTop(4f);
}).padTop(5).growX().top();
mid.row();
mid.table(t -> {
t.button("@editor.center", () -> view.center()).growX();
}).pad(-5).style(Styles.squaret).growX().top();
}).margin(0).left().growY();

View File

@ -171,6 +171,10 @@ public class MapView extends Element implements GestureListener{
this.grid = grid;
}
public void center(){
offsetx = offsety = 0;
}
@Override
public void act(float delta){
super.act(delta);

View File

@ -22,6 +22,7 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
float scl = 5f;
float waterOffset = 0.07f;
//TODO fix sand near snow (sector 173)
Block[][] arr =
{
{Blocks.water, Blocks.darksandWater, Blocks.darksand, Blocks.darksand, Blocks.darksand, Blocks.darksand, Blocks.sand, Blocks.sand, Blocks.sand, Blocks.sand, Blocks.darksandTaintedWater, Blocks.stone, Blocks.stone},

View File

@ -496,8 +496,24 @@ public class Tile implements Position, QuadTreeObject, Displayable{
protected void changeEntity(Team team, Prov<Building> entityprov, int rotation){
if(build != null){
int size = build.block.size;
build.remove();
build = null;
//update edge entities
tileSet.clear();
for(Point2 edge : Edges.getEdges(size)){
Building other = world.build(x + edge.x, y + edge.y);
if(other != null){
tileSet.add(other);
}
}
//update proximity, since multiblock was just removed
for(Building t : tileSet){
t.updateProximity();
}
}
if(block.hasBuilding()){

View File

@ -2,11 +2,13 @@ package mindustry.world.blocks.environment;
import arc.graphics.g2d.*;
import arc.util.*;
import mindustry.annotations.Annotations.*;
import mindustry.graphics.*;
import mindustry.world.*;
public class Cliff extends Block{
public float size = 11f;
public @Load(value = "cliffmask#", length = 256) TextureRegion[] cliffs;
public Cliff(String name){
super(name);
@ -19,15 +21,8 @@ public class Cliff extends Block{
@Override
public void drawBase(Tile tile){
int r = tile.data;
for(int i = 0; i < 8; i++){
if((r & (1 << i)) != 0){
Draw.color(Tmp.c1.set(tile.floor().mapColor).mul(1.3f + (i >= 4 ? -0.4f : 0.3f)));
Draw.rect(region, tile.worldx(), tile.worldy(), size, size, i * 45f);
}
}
Draw.color(Tmp.c1.set(tile.floor().mapColor).mul(1.6f));
Draw.rect(cliffs[tile.data & 0xff], tile.worldx(), tile.worldy());
Draw.color();
}

View File

@ -78,6 +78,79 @@ public class Generators{
}
});
ImagePacker.generate("cliffs", () -> {
int size = 64;
Color dark = new Color(0.5f, 0.5f, 0.6f, 1f).mul(0.98f);
Color mid = Color.lightGray;
Image[] images = new Image[8];
for(int i = 0; i < 8; i++){
images[i] = ImagePacker.get("cliff" + i);
}
for(int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++){
Image result = new Image(size, size);
byte[][] mask = new byte[size][size];
byte val = (byte)i;
//check each bit/direction
for(int j = 0; j < 8; j++){
if((val & (1 << j)) != 0){
if(j % 2 == 1 && (((val & (1 << (j + 1))) != 0) != ((val & (1 << (j - 1))) != 0))){
continue;
}
Image image = images[j];
image.each((x, y) -> {
Color color = image.getColor(x, y);
if(color.a > 0.1){
//white -> bit 1 -> top
//black -> bit 2 -> bottom
mask[x][y] |= (color.r > 0.5f ? 1 : 2);
}
});
}
}
result.each((x, y) -> {
byte m = mask[x][y];
if(m != 0){
//mid
if(m == 3){
//find nearest non-mid color
byte best = 0;
float bestDst = 0;
boolean found = false;
//expand search range until found
for(int rad = 9; rad < 64; rad += 7){
for(int cx = Math.max(x - rad, 0); cx <= Math.min(x + rad, size - 1); cx++){
for(int cy = Math.max(y - rad, 0); cy <= Math.min(y + rad, size - 1); cy++){
byte nval = mask[cx][cy];
if(nval == 1 || nval == 2){
float dst2 = Mathf.dst2(cx, cy, x, y);
if(dst2 <= rad * rad && (!found || dst2 < bestDst)){
best = nval;
bestDst = dst2;
found = true;
}
}
}
}
}
if(found){
m = best;
}
}
result.draw(x, y, m == 1 ? Color.white : m == 2 ? dark : mid);
}
});
result.save("../blocks/environment/cliffmask" + (val & 0xff));
}
});
ImagePacker.generate("cracks", () -> {
RidgedPerlin r = new RidgedPerlin(1, 3);
for(int size = 1; size <= Block.maxCrackSize; size++){