mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-30 17:34:23 +07:00
Added FPS cap setting / Bugfixes
This commit is contained in:
parent
01300b97e2
commit
ecf9a3cbc9
@ -322,6 +322,9 @@ text.category.liquids=Liquids
|
||||
text.category.items=Items
|
||||
text.category.crafting=Crafting
|
||||
text.category.shooting=Shooting
|
||||
setting.fpscap.name=Max FPS
|
||||
setting.fpscap.none=None
|
||||
setting.fpscap.text={0} FPS
|
||||
setting.difficulty.easy=easy
|
||||
setting.difficulty.normal=normal
|
||||
setting.difficulty.hard=hard
|
||||
|
@ -35,8 +35,9 @@ public class Mindustry extends ModuleCore{
|
||||
|
||||
@Override
|
||||
public void render(){
|
||||
threads.handleBeginRender();
|
||||
super.render();
|
||||
threads.handleRender();
|
||||
threads.handleEndRender();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -76,12 +76,12 @@ public class TurretBullets extends BulletList implements ContentList{
|
||||
}
|
||||
};
|
||||
|
||||
basicFlame = new BulletType(2f, 5){
|
||||
basicFlame = new BulletType(2.3f, 5){
|
||||
{
|
||||
hitsize = 7f;
|
||||
lifetime = 30f;
|
||||
lifetime = 35f;
|
||||
pierce = true;
|
||||
drag = 0.07f;
|
||||
drag = 0.05f;
|
||||
hiteffect = BulletFx.hitFlameSmall;
|
||||
despawneffect = Fx.none;
|
||||
status = StatusEffects.burning;
|
||||
|
@ -75,7 +75,7 @@ public class ShootFx extends FxList implements ContentList{
|
||||
shootSmallFlame = new Effect(30f, e -> {
|
||||
Draw.color(Palette.lightFlame, Palette.darkFlame, Color.GRAY, e.fin());
|
||||
|
||||
Angles.randLenVectors(e.id, 8, e.finpow() * 26f, e.rotation, 10f, (x, y) -> {
|
||||
Angles.randLenVectors(e.id, 8, e.finpow() * 36f, e.rotation, 10f, (x, y) -> {
|
||||
Fill.circle(e.x + x, e.y + y, 0.65f + e.fout() * 1.5f);
|
||||
});
|
||||
|
||||
|
@ -3,6 +3,7 @@ package io.anuke.mindustry.core;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.utils.Queue;
|
||||
import com.badlogic.gdx.utils.TimeUtils;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.util.Log;
|
||||
|
||||
@ -19,6 +20,7 @@ public class ThreadHandler{
|
||||
private float framesSinceUpdate;
|
||||
private boolean enabled;
|
||||
private boolean rendered = true;
|
||||
private long lastFrameTime;
|
||||
|
||||
public ThreadHandler(ThreadProvider impl){
|
||||
this.impl = impl;
|
||||
@ -69,7 +71,24 @@ public class ThreadHandler{
|
||||
return framesSinceUpdate;
|
||||
}
|
||||
|
||||
public void handleRender(){
|
||||
public void handleBeginRender(){
|
||||
lastFrameTime = TimeUtils.millis();
|
||||
}
|
||||
|
||||
public void handleEndRender(){
|
||||
int fpsCap = Settings.getInt("fpscap", 125);
|
||||
|
||||
if(fpsCap <= 120){
|
||||
long target = 1000/fpsCap;
|
||||
long elapsed = TimeUtils.timeSinceMillis(lastFrameTime);
|
||||
if(elapsed < target){
|
||||
try{
|
||||
impl.sleep(target - elapsed);
|
||||
}catch(InterruptedException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!enabled) return;
|
||||
|
||||
|
@ -134,6 +134,10 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
//game.sliderPref("sensitivity", 100, 10, 300, i -> i + "%");
|
||||
game.sliderPref("saveinterval", 90, 10, 5 * 120, i -> Bundles.format("setting.seconds", i));
|
||||
|
||||
if(!gwt){
|
||||
graphics.sliderPref("fpscap", 125, 5, 125, 5, s -> (s > 120 ? Bundles.get("setting.fpscap.none") : Bundles.format("setting.fpscap.text", s)));
|
||||
}
|
||||
|
||||
if(!gwt){
|
||||
graphics.checkPref("multithread", true, threads::setEnabled);
|
||||
|
||||
|
@ -40,8 +40,8 @@ public abstract class LiquidTurret extends Turret{
|
||||
|
||||
TurretEntity entity = tile.entity();
|
||||
|
||||
Effects.effect(shootEffect, type.liquid.color, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
|
||||
Effects.effect(smokeEffect, type.liquid.color, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
|
||||
Effects.effect(type.shootEffect, type.liquid.color, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
|
||||
Effects.effect(type.smokeEffect, type.liquid.color, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
|
||||
|
||||
if(shootShake > 0){
|
||||
Effects.shake(shootShake, shootShake, tile.entity);
|
||||
|
@ -141,11 +141,6 @@ public class Conveyor extends Block{
|
||||
return super.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLayer(Tile tile){
|
||||
return tile.<ConveyorEntity>entity().convey.size > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLayer(Tile tile){
|
||||
ConveyorEntity entity = tile.entity();
|
||||
@ -265,7 +260,9 @@ public class Conveyor extends Block{
|
||||
entity.carrying = 0f;
|
||||
entity.minCarry = 2f;
|
||||
|
||||
if(totalMoved/Timers.delta() <= 0.0001f){
|
||||
Tile next = tile.getNearby(tile.getRotation());
|
||||
|
||||
if((next != null && next.block() instanceof Conveyor) && totalMoved/Timers.delta() <= 0.0001f){
|
||||
entity.sleep();
|
||||
}else{
|
||||
entity.noSleep();
|
||||
|
Loading…
Reference in New Issue
Block a user