diff --git a/core/src/com/me/brickbuster/BrickBuster.java b/core/src/com/me/brickbuster/BrickBuster.java index a515082..a9b08a1 100644 --- a/core/src/com/me/brickbuster/BrickBuster.java +++ b/core/src/com/me/brickbuster/BrickBuster.java @@ -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 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(); @@ -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) {