uCore surface support

This commit is contained in:
Anuken 2017-05-14 22:49:31 -04:00
parent e0a1e75203
commit b8b3848e5e
5 changed files with 16 additions and 43 deletions

View File

@ -19,9 +19,10 @@ public class Control extends RendererModule{
//GifRecorder recoder = new GifRecorder(batch);
public Control(){
cameraScale = 4f;
setPixelation();
buffers.add("shadow", (int) (Gdx.graphics.getWidth() / cameraScale), (int) (Gdx.graphics.getHeight() / cameraScale));
cameraScale = 4;
pixelate();
Draw.addSurface("shadow", cameraScale);
atlas = new Atlas("mindustry.atlas");
@ -146,10 +147,7 @@ public class Control extends RendererModule{
@Override
public void resize(int width, int height){
super.resize(width, height);
buffers.remove("shadow");
buffers.add("shadow", (int) (Gdx.graphics.getWidth() / cameraScale), (int) (Gdx.graphics.getHeight() / cameraScale));
rangex = (int) (width / tilesize / cameraScale/2)+2;
rangey = (int) (height / tilesize / cameraScale/2)+2;
}

View File

@ -2,12 +2,9 @@ package io.anuke.mindustry;
import static io.anuke.mindustry.Vars.*;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Buttons;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.math.MathUtils;
import io.anuke.mindustry.entities.TileEntity;
@ -20,7 +17,6 @@ import io.anuke.ucore.core.Inputs;
import io.anuke.ucore.entities.DestructibleEntity;
import io.anuke.ucore.entities.Entities;
import io.anuke.ucore.entities.Entity;
import io.anuke.ucore.graphics.FrameBufferMap;
import io.anuke.ucore.scene.utils.Cursors;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Timers;
@ -29,21 +25,12 @@ public class Renderer{
public static void renderTiles(){
Draw.clear();
Batch batch = control.batch;
FrameBufferMap buffers = control.buffers;
OrthographicCamera camera = control.camera;
int rangex = control.rangex, rangey = control.rangey;
for(int l = 0; l < 4; l++){
if(l == 1){
batch.end();
buffers.end("pixel");
buffers.begin("shadow");
batch.begin();
Gdx.gl.glClearColor(0, 0, 0, 0);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
Draw.surface("shadow");
}
for(int x = -rangex; x <= rangex; x++){
@ -66,17 +53,9 @@ public class Renderer{
}
if(l == 1){
batch.end();
buffers.end("shadow");
batch.setColor(0, 0, 0, 0.15f);
buffers.begin("pixel");
control.drawFull("shadow");
batch.setColor(Color.WHITE);
batch.setProjectionMatrix(camera.combined);
batch.begin();
Draw.color(0, 0, 0, 0.15f);
Draw.flushSurface();
Draw.color();
}
}
}

View File

@ -54,8 +54,8 @@ public class UI extends SceneModule{
Batch batch = scene.getBatch();
Draw.color();
int w = gwidth();
int h = gheight();
int w = (int)screen.x;
int h = (int)screen.y;
Draw.color(Hue.lightness(0.6f));
@ -331,15 +331,15 @@ public class UI extends SceneModule{
aleft();
abottom();
new button("+", ()->{
if(control.cameraScale < 4f){
control.cameraScale = 4f;
if(control.cameraScale < 4){
control.cameraScale = 4;
control.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
}).size(40);
new button("-", ()->{
if(control.cameraScale > 3f){
control.cameraScale = 3f;
if(control.cameraScale > 3){
control.cameraScale = 3;
control.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
}).size(40);

View File

@ -19,7 +19,7 @@ public class Vars{
public static final float wavespace = 20*60;
public static final float enemyspawnspace = 65;
public static final float breakduration = 30;
public static boolean debug = true;
public static boolean debug = false;
public static final Vector2 vector = new Vector2();

View File

@ -34,10 +34,6 @@ public class Player extends DestructibleEntity{
respawntime = respawnduration;
}
@Override
public void removed(){
}
@Override
public void draw(){
Draw.rect("player", x, y, direction.angle()-90);