Add vSync, fix multiple bugs

This commit is contained in:
Anuken
2017-12-20 22:06:36 -05:00
parent ddb7c32491
commit 7b8de91b8c
5 changed files with 15 additions and 47 deletions

View File

@ -40,7 +40,7 @@ public class Vars{
//how much the zoom changes every zoom button press
public static final int zoomScale = Math.round(Unit.dp.scl(1));
//if true, player speed will be increased, massive amounts of resources will be given on start, and other debug options will be available
public static boolean debug = false;
public static boolean debug = true;
//whether the player can clip through walls
public static boolean noclip = false;
//whether to draw chunk borders

View File

@ -163,13 +163,7 @@ public class UI extends SceneModule{
configtable = new Table();
scene.add(configtable);
try {
editorDialog = new MapEditorDialog(editor);
}catch (Exception e){
Timers.run(1f, () -> {
showErrorClose("[orange]Error occurred loading editor![]Are you running from a zip file?\n");
});
}
editorDialog = new MapEditorDialog(editor);
settingserror = new Dialog("Warning", "dialog");
settingserror.content().add("[crimson]Failed to access local storage.\nSettings will not be saved.");
@ -210,6 +204,7 @@ public class UI extends SceneModule{
prefs.volumePrefs();
prefs.checkPref("fps", "Show FPS", false);
prefs.checkPref("vsync", "VSync", true, b -> Gdx.graphics.setVSync(b));
prefs.checkPref("noshadows", "Disable shadows", false);
prefs.checkPref("smoothcam", "Smooth Camera", true);
prefs.checkPref("indicators", "Enemy Indicators", true);
@ -226,6 +221,8 @@ public class UI extends SceneModule{
}
renderer.setPixelate(b);
});
Gdx.graphics.setVSync(Settings.getBool("vsync"));
prefs.hidden(()->{
if(!GameState.is(State.menu)){

View File

@ -9,6 +9,7 @@ import io.anuke.mindustry.entities.*;
import io.anuke.mindustry.graphics.Fx;
import io.anuke.mindustry.graphics.Shaders;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.UCore;
import io.anuke.ucore.core.*;
import io.anuke.ucore.entities.*;
import io.anuke.ucore.util.*;
@ -152,41 +153,6 @@ public class Enemy extends DestructibleEntity{
Bullet out = new Bullet(bullet, this, x + Angles.x(), y + Angles.y(), this.angle + rotation).add();
out.damage = (int) (damage * Vars.multiplier);
}
/*
public void findClosestNode(){
int index = 0;
int cindex = -1;
float dst = Float.MAX_VALUE;
UCore.log("Finding closest.");
Tile[] clone = path.clone();
UCore.log(clone.length);
//find closest node index
for(Tile tile : path){
if(Vector2.dst(tile.worldx(), tile.worldy(), x, y) < dst){
dst = Vector2.dst(tile.worldx(), tile.worldy(), x, y);
cindex = index;
}
index++;
}
cindex = Math.max(cindex, 1);
//set node to that index
node = cindex;
int x2 = path[node].x, y2 = path[node].y;
//if the enemy can't move to that node right now, set its position to it
if(Vars.world.raycast(Mathf.scl2(x, Vars.tilesize), Mathf.scl2(y, Vars.tilesize), x2, y2) != null){
Timers.run(Mathf.random(15f), () -> {
set(x2 * Vars.tilesize, y2 * Vars.tilesize);
});
}
}*/
@Override
public void added(){
@ -240,7 +206,7 @@ public class Enemy extends DestructibleEntity{
float minv = 0.07f;
if(xvelocity < minv && yvelocity < minv && node > 0 && target == null){
if(Math.abs(xvelocity) < minv && Math.abs(yvelocity) < minv && node > 0 && target == null){
idletime += Timers.delta();
}else{
idletime = 0;
@ -271,8 +237,14 @@ public class Enemy extends DestructibleEntity{
if(Vars.showPaths){
Draw.color(Color.PURPLE);
Draw.line(x, y, x + xvelocity*10f, y + yvelocity*10f);
Draw.color(Color.BLACK, Color.WHITE, idletime / maxIdleLife);
Draw.square(x, y, 7f);
Draw.color();
}
Draw.color();
Graphics.flush();
}

View File

@ -155,6 +155,7 @@ public class Block{
tile.setDump((byte)((i+1)%4));
return;
}
tiles = tile.getNearby();
i++;
i %= 4;
}
@ -191,6 +192,7 @@ public class Block{
}
}
}
tiles = tile.getNearby();
i++;
i %= 4;
}

View File

@ -23,8 +23,6 @@ public class Junction extends Block{
public void handleItem(Item item, Tile tile, Tile source){
int dir = source.relativeTo(tile.x, tile.y);
Tile to = tile.getNearby()[dir];
UCore.log("handling to " + to + " from " + source + ", tile = " + tile);
Timers.run(15, ()->{
if(to == null || to.entity == null) return;
@ -38,7 +36,6 @@ public class Junction extends Block{
int dir = source.relativeTo(dest.x, dest.y);
if(dir == -1) return false;
Tile to = dest.getNearby()[dir];
UCore.log("outputting to " + to + " " + to.block().acceptItem(item, to, dest) + " from " + source);
return to != null && to.block().acceptItem(item, to, dest);
}