Implemented block build animation and shaders
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package io.anuke.mindustry.graphics;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
@@ -8,7 +7,6 @@ import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.types.StaticBlock;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
@@ -60,7 +58,7 @@ public class BlockRenderer{
|
||||
|
||||
int expandr = 4;
|
||||
|
||||
Graphics.surface(renderer.shadowSurface);
|
||||
Graphics.surface(renderer.effectSurface);
|
||||
|
||||
for(int x = -rangex - expandr; x <= rangex + expandr; x++){
|
||||
for(int y = -rangey - expandr; y <= rangey + expandr; y++){
|
||||
|
||||
@@ -66,20 +66,20 @@ public enum CacheLayer {
|
||||
|
||||
protected void beginShader(){
|
||||
//renderer.getBlocks().endFloor();
|
||||
renderer.waterSurface.getBuffer().begin();
|
||||
renderer.effectSurface.getBuffer().begin();
|
||||
Graphics.clear(Color.CLEAR);
|
||||
//renderer.getBlocks().beginFloor();
|
||||
}
|
||||
|
||||
public void endShader(Shader shader){
|
||||
renderer.getBlocks().endFloor();
|
||||
renderer.waterSurface.getBuffer().end();
|
||||
renderer.effectSurface.getBuffer().end();
|
||||
|
||||
renderer.pixelSurface.getBuffer().begin();
|
||||
|
||||
Graphics.shader(shader);
|
||||
Graphics.begin();
|
||||
Draw.rect(renderer.waterSurface.texture(), Core.camera.position.x, Core.camera.position.y,
|
||||
Draw.rect(renderer.effectSurface.texture(), Core.camera.position.x, Core.camera.position.y,
|
||||
Core.camera.viewportWidth * Core.camera.zoom, -Core.camera.viewportHeight * Core.camera.zoom);
|
||||
Graphics.end();
|
||||
Graphics.shader();
|
||||
|
||||
@@ -3,6 +3,8 @@ package io.anuke.mindustry.graphics;
|
||||
public enum Layer{
|
||||
/**Base block layer.*/
|
||||
block,
|
||||
/**for placement*/
|
||||
placement,
|
||||
/**First overlay. Stuff like conveyor items.*/
|
||||
overlay,
|
||||
/**"High" blocks, like turrets.*/
|
||||
|
||||
@@ -15,6 +15,7 @@ import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class Shaders{
|
||||
public static final Outline outline = new Outline();
|
||||
public static final Inline inline = new Inline();
|
||||
public static final Shield shield = new Shield();
|
||||
public static final SurfaceShader water = new SurfaceShader("water");
|
||||
public static final SurfaceShader lava = new SurfaceShader("lava");
|
||||
@@ -71,6 +72,25 @@ public class Shaders{
|
||||
shader.setUniformf("u_texsize", vec.set(region.getTexture().getWidth(), region.getTexture().getHeight()));
|
||||
}
|
||||
}
|
||||
|
||||
public static class Inline extends Shader{
|
||||
public Color color = new Color();
|
||||
public float progress;
|
||||
|
||||
public Inline(){
|
||||
super("inline-lines", "default");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
shader.setUniformf("u_progress", progress);
|
||||
shader.setUniformf("u_color", color);
|
||||
shader.setUniformf("u_uv", region.getU(), region.getV());
|
||||
shader.setUniformf("u_uv2", region.getU2(), region.getV2());
|
||||
shader.setUniformf("u_time", Timers.time());
|
||||
shader.setUniformf("u_texsize", vec.set(region.getTexture().getWidth(), region.getTexture().getHeight()));
|
||||
}
|
||||
}
|
||||
|
||||
public static class Shield extends Shader{
|
||||
public static final int MAX_HITS = 3*64;
|
||||
|
||||
Reference in New Issue
Block a user