1. Home
  2. /
  3. Libgdx
  4. /
  5. FPS Display

FPS Display - Libgdx Typing CST Test

Loading…

FPS Display — Libgdx Code

Shows frames per second on screen.

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;

public class FpsDemo extends ApplicationAdapter {
	private SpriteBatch batch;
	private BitmapFont font;

	@Override
	public void create() {
		batch = new SpriteBatch();
		font = new BitmapFont();
	}

	@Override
	public void render() {
		int fps = Gdx.graphics.getFramesPerSecond();
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		batch.begin();
		font.draw(batch, "FPS: " + fps, 30, 150);
		batch.end();
	}
}

Libgdx Language Guide

LibGDX is a powerful, open-source Java game framework for building high-performance 2D and 3D games that run on desktop, Android, iOS, and web through a single shared codebase.

Primary Use Cases

  • ▸Cross-platform 2D and 3D games
  • ▸Android-first game development
  • ▸Custom in-house engines
  • ▸Scientific/physics simulations
  • ▸Desktop games with OpenGL rendering

Notable Features

  • ▸Single Java/Kotlin codebase -> multiple platforms
  • ▸Scene2D UI and Scene2D stage/actors
  • ▸Built-in physics via Box2D
  • ▸OpenGL-based rendering pipeline
  • ▸Powerful math + linear algebra library

Origin & Creator

LibGDX was created by Mario Zechner and maintained by a global open-source community focused on flexible, high-performance Java game development.

Industrial Note

LibGDX thrives in Android game development, indie 2D/3D engines, simulation-heavy games, and education-especially for teams needing full control without being locked into heavy engines.

More Libgdx Typing Exercises

LibGDX Simple Counter GameLibGDX Sprite MovementLibGDX Clear Screen ColorLibGDX Animation ExampleLibGDX Keyboard Text InputLibGDX Timer EventLibGDX Mouse TrackerLibGDX Sound PlaybackLibGDX Touch ExampleLibGDX Random Walker

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher