Add vSync, fix multiple bugs
This commit is contained in:
@@ -40,7 +40,7 @@ public class Vars{
|
|||||||
//how much the zoom changes every zoom button press
|
//how much the zoom changes every zoom button press
|
||||||
public static final int zoomScale = Math.round(Unit.dp.scl(1));
|
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
|
//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
|
//whether the player can clip through walls
|
||||||
public static boolean noclip = false;
|
public static boolean noclip = false;
|
||||||
//whether to draw chunk borders
|
//whether to draw chunk borders
|
||||||
|
|||||||
@@ -163,13 +163,7 @@ public class UI extends SceneModule{
|
|||||||
configtable = new Table();
|
configtable = new Table();
|
||||||
scene.add(configtable);
|
scene.add(configtable);
|
||||||
|
|
||||||
try {
|
editorDialog = new MapEditorDialog(editor);
|
||||||
editorDialog = new MapEditorDialog(editor);
|
|
||||||
}catch (Exception e){
|
|
||||||
Timers.run(1f, () -> {
|
|
||||||
showErrorClose("[orange]Error occurred loading editor![]Are you running from a zip file?\n");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
settingserror = new Dialog("Warning", "dialog");
|
settingserror = new Dialog("Warning", "dialog");
|
||||||
settingserror.content().add("[crimson]Failed to access local storage.\nSettings will not be saved.");
|
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.volumePrefs();
|
||||||
|
|
||||||
prefs.checkPref("fps", "Show FPS", false);
|
prefs.checkPref("fps", "Show FPS", false);
|
||||||
|
prefs.checkPref("vsync", "VSync", true, b -> Gdx.graphics.setVSync(b));
|
||||||
prefs.checkPref("noshadows", "Disable shadows", false);
|
prefs.checkPref("noshadows", "Disable shadows", false);
|
||||||
prefs.checkPref("smoothcam", "Smooth Camera", true);
|
prefs.checkPref("smoothcam", "Smooth Camera", true);
|
||||||
prefs.checkPref("indicators", "Enemy Indicators", true);
|
prefs.checkPref("indicators", "Enemy Indicators", true);
|
||||||
@@ -227,6 +222,8 @@ public class UI extends SceneModule{
|
|||||||
renderer.setPixelate(b);
|
renderer.setPixelate(b);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Gdx.graphics.setVSync(Settings.getBool("vsync"));
|
||||||
|
|
||||||
prefs.hidden(()->{
|
prefs.hidden(()->{
|
||||||
if(!GameState.is(State.menu)){
|
if(!GameState.is(State.menu)){
|
||||||
if(!wasPaused)
|
if(!wasPaused)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import io.anuke.mindustry.entities.*;
|
|||||||
import io.anuke.mindustry.graphics.Fx;
|
import io.anuke.mindustry.graphics.Fx;
|
||||||
import io.anuke.mindustry.graphics.Shaders;
|
import io.anuke.mindustry.graphics.Shaders;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.ucore.UCore;
|
||||||
import io.anuke.ucore.core.*;
|
import io.anuke.ucore.core.*;
|
||||||
import io.anuke.ucore.entities.*;
|
import io.anuke.ucore.entities.*;
|
||||||
import io.anuke.ucore.util.*;
|
import io.anuke.ucore.util.*;
|
||||||
@@ -153,41 +154,6 @@ public class Enemy extends DestructibleEntity{
|
|||||||
out.damage = (int) (damage * Vars.multiplier);
|
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
|
@Override
|
||||||
public void added(){
|
public void added(){
|
||||||
if(bullet != null){
|
if(bullet != null){
|
||||||
@@ -240,7 +206,7 @@ public class Enemy extends DestructibleEntity{
|
|||||||
|
|
||||||
float minv = 0.07f;
|
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();
|
idletime += Timers.delta();
|
||||||
}else{
|
}else{
|
||||||
idletime = 0;
|
idletime = 0;
|
||||||
@@ -271,9 +237,15 @@ public class Enemy extends DestructibleEntity{
|
|||||||
if(Vars.showPaths){
|
if(Vars.showPaths){
|
||||||
Draw.color(Color.PURPLE);
|
Draw.color(Color.PURPLE);
|
||||||
Draw.line(x, y, x + xvelocity*10f, y + yvelocity*10f);
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Draw.color();
|
||||||
|
|
||||||
Graphics.flush();
|
Graphics.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ public class Block{
|
|||||||
tile.setDump((byte)((i+1)%4));
|
tile.setDump((byte)((i+1)%4));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
tiles = tile.getNearby();
|
||||||
i++;
|
i++;
|
||||||
i %= 4;
|
i %= 4;
|
||||||
}
|
}
|
||||||
@@ -191,6 +192,7 @@ public class Block{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tiles = tile.getNearby();
|
||||||
i++;
|
i++;
|
||||||
i %= 4;
|
i %= 4;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,6 @@ public class Junction extends Block{
|
|||||||
int dir = source.relativeTo(tile.x, tile.y);
|
int dir = source.relativeTo(tile.x, tile.y);
|
||||||
Tile to = tile.getNearby()[dir];
|
Tile to = tile.getNearby()[dir];
|
||||||
|
|
||||||
UCore.log("handling to " + to + " from " + source + ", tile = " + tile);
|
|
||||||
|
|
||||||
Timers.run(15, ()->{
|
Timers.run(15, ()->{
|
||||||
if(to == null || to.entity == null) return;
|
if(to == null || to.entity == null) return;
|
||||||
to.block().handleItem(item, to, tile);
|
to.block().handleItem(item, to, tile);
|
||||||
@@ -38,7 +36,6 @@ public class Junction extends Block{
|
|||||||
int dir = source.relativeTo(dest.x, dest.y);
|
int dir = source.relativeTo(dest.x, dest.y);
|
||||||
if(dir == -1) return false;
|
if(dir == -1) return false;
|
||||||
Tile to = dest.getNearby()[dir];
|
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);
|
return to != null && to.block().acceptItem(item, to, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user