Skip to content

Instantly share code, notes, and snippets.

Last active January 2, 2016 20:59
Show Gist options
  • Save kotcrab/8360067 to your computer and use it in GitHub Desktop.
Save kotcrab/8360067 to your computer and use it in GitHub Desktop.
Box2dTutorial - Code 1
package pl.kotcrab.libgdxtests;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer;
import com.badlogic.gdx.physics.box2d.World;
public class Box2dTester implements ApplicationListener
private OrthographicCamera camera;
static final float WORLD_TO_BOX = 0.01f;
static final float BOX_TO_WORLD = 100f;
private World world;
private Box2DDebugRenderer debugRenderer;
public void create()
camera = new OrthographicCamera(800, 480);
camera.position.x = 400;
camera.position.y = 240;
world = new World(new Vector2(0, -10), true);
debugRenderer = new Box2DDebugRenderer();
public void render()
{, 0, 0, 1);;
world.step(1 / 60f, 6, 2);
debugRenderer.render(world, camera.combined.scl(BOX_TO_WORLD));
public void dispose()
@Override public void pause(){}
@Override public void resume(){}
@Override public void resize(int width, int height){}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment