Add debug info to bottom left of screen
This commit is contained in:
parent
5e3f71f236
commit
ed8c90be1a
@ -3,6 +3,8 @@ package com.me.brickbuster;
|
||||
import com.badlogic.gdx.ApplicationAdapter;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.me.brickbuster.entity.*;
|
||||
@ -22,6 +24,9 @@ public class BrickBuster extends ApplicationAdapter {
|
||||
public static final Vector2 HORIZONTAL_EDGE = new Vector2(1, 0);
|
||||
public static final Vector2 VERTICAL_EDGE = new Vector2(0, 1);
|
||||
|
||||
private BitmapFont font;
|
||||
private SpriteBatch batch;
|
||||
|
||||
private Ball ball;
|
||||
private Paddle paddle;
|
||||
private ArrayList<Brick> bricks;
|
||||
@ -30,6 +35,9 @@ public class BrickBuster extends ApplicationAdapter {
|
||||
|
||||
@Override
|
||||
public void create () {
|
||||
font = new BitmapFont();
|
||||
batch = new SpriteBatch();
|
||||
|
||||
ball = new Ball(this);
|
||||
paddle = new Paddle(this);
|
||||
powerUps = new ArrayList<PowerUp>();
|
||||
@ -52,21 +60,29 @@ public class BrickBuster extends ApplicationAdapter {
|
||||
|
||||
@Override
|
||||
public void render () {
|
||||
update(Gdx.graphics.getDeltaTime());
|
||||
|
||||
Gdx.gl.glClearColor(0.5f,1,1,1);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
long start_update = System.nanoTime();
|
||||
update(Gdx.graphics.getDeltaTime());
|
||||
long finish_update = System.nanoTime() - start_update;
|
||||
|
||||
long start_render = System.nanoTime();
|
||||
for (Brick block : bricks) {
|
||||
block.render();
|
||||
}
|
||||
|
||||
for (PowerUp powerUp : powerUps) {
|
||||
powerUp.render();
|
||||
}
|
||||
|
||||
ball.render();
|
||||
paddle.render();
|
||||
long finish_render = System.nanoTime() - start_render;
|
||||
|
||||
batch.begin();
|
||||
//batch.setColor(Color.BLACK);
|
||||
font.draw(batch, String.format("FPS: %d Update: %.2f ms Render: %.2f ms",
|
||||
Gdx.graphics.getFramesPerSecond(), finish_update/1000000f, finish_render/1000000f), 0, 13);
|
||||
batch.end();
|
||||
}
|
||||
|
||||
public void update(float dt) {
|
||||
|
Loading…
Reference in New Issue
Block a user