Added a sprite in preparation for incoming updates & added delta counter.
This commit is contained in:
parent
bf915e7daa
commit
f87f44da51
BIN
core/assets/sprites/testBackground.png
Normal file
BIN
core/assets/sprites/testBackground.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 901 KiB |
@ -25,7 +25,6 @@ import com.saltosion.gladiator.gui.TextNode;
|
|||||||
import com.saltosion.gladiator.gui.TextProperty;
|
import com.saltosion.gladiator.gui.TextProperty;
|
||||||
import com.saltosion.gladiator.util.AppUtil;
|
import com.saltosion.gladiator.util.AppUtil;
|
||||||
import com.saltosion.gladiator.util.Global;
|
import com.saltosion.gladiator.util.Global;
|
||||||
import com.saltosion.gladiator.util.Log;
|
|
||||||
import com.saltosion.gladiator.util.SpriteSequence;
|
import com.saltosion.gladiator.util.SpriteSequence;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -48,6 +47,11 @@ public class RenderingSystem extends EntitySystem {
|
|||||||
private boolean debug = true;
|
private boolean debug = true;
|
||||||
private final Color debugColor = new Color(0, 1, 0, 1);
|
private final Color debugColor = new Color(0, 1, 0, 1);
|
||||||
|
|
||||||
|
private float deltaDelay = 0;
|
||||||
|
private double deltaAvgSum;
|
||||||
|
private long deltaAvgTimes;
|
||||||
|
private String deltaString = "0";
|
||||||
|
|
||||||
private List<TextObject> drawableText;
|
private List<TextObject> drawableText;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -90,10 +94,33 @@ public class RenderingSystem extends EntitySystem {
|
|||||||
renderGUI(new Vector2(0, 0));
|
renderGUI(new Vector2(0, 0));
|
||||||
renderDebug(camera);
|
renderDebug(camera);
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
drawString("FPS: " + Gdx.graphics.getFramesPerSecond(), new Vector2(camera.position.x - 12, camera.position.y + 8));
|
drawString("FPS: " + Gdx.graphics.getFramesPerSecond(), new Vector2(camera.position.x - 12, camera.position.y + 8));
|
||||||
|
drawString("Delta (ms): " + getDeltaWithDelay(deltaTime, 0.1f), new Vector2(camera.position.x - 12, camera.position.y + 7));
|
||||||
|
}
|
||||||
renderFont(fontCamera);
|
renderFont(fontCamera);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A debugging function for easier performance logging.
|
||||||
|
*
|
||||||
|
* @param deltaTime The delta of the current frame
|
||||||
|
* @param delay The delay between deltaString updates
|
||||||
|
* @return A string that has the delta formatted
|
||||||
|
*/
|
||||||
|
private String getDeltaWithDelay(float deltaTime, float delay) {
|
||||||
|
this.deltaDelay += deltaTime;
|
||||||
|
this.deltaAvgSum += Gdx.graphics.getDeltaTime() * 1000;
|
||||||
|
this.deltaAvgTimes++;
|
||||||
|
if (this.deltaDelay >= delay) {
|
||||||
|
this.deltaDelay = 0;
|
||||||
|
this.deltaString = String.format("%.2f", this.deltaAvgSum / this.deltaAvgTimes);
|
||||||
|
this.deltaAvgSum = 0;
|
||||||
|
this.deltaAvgTimes = 0;
|
||||||
|
}
|
||||||
|
return deltaString;
|
||||||
|
}
|
||||||
|
|
||||||
private void renderEntities(float deltaTime) {
|
private void renderEntities(float deltaTime) {
|
||||||
batch.setProjectionMatrix(camera.combined);
|
batch.setProjectionMatrix(camera.combined);
|
||||||
batch.begin();
|
batch.begin();
|
||||||
|
Loading…
Reference in New Issue
Block a user