Questions tagged [jbox2d]

JBox2D is a Java physics engine often used in games an other physics simulations and is a port/extension of the C++ physics engine, Box2D.

JBox2D is a physics engine for Java often used in games and other physics simulations, and is a port/extension of the C++ physics engine, Box2D.

Questions

Questions with the jbox2d tag should be specifically about JBox2D and its implementation. Questions about the physics engine in general should be tagged with box2d as well.

Brief Definitions

  • World contains the physics environment for a simulation
  • Body is a physics entity with any number of child fixtures. These fixtures are treated as all part of the same physics object, and will interact accordingly (they won't break up). Bodies also provide support for user-applied forces and torque.
  • Fixture contains a single shape and information about it (for example, friction and restitution).
  • Shape contains information about the basic physical properties of the physics object. (for example, the vertices of the polygon shape)
  • Joint is basically a way of adding constraints to different bodies. There are a variety of joints, including revolute, distance, and prismatic joints.

Links

JBox2D

Box2D

183 questions
0
votes
2 answers

Rotate an opengl shape as box2d body rotates

I have a simple Java app setup which uses JOGL and JBox2D. Below is how the app renders .. 3 Rectangles, 2 are Dynamic and 1 is Static i.e. the ground. I can move 1 of the Rectangles left, right or by jumping using a KeyListener and adjusting the…
bobbyrne01
  • 6,295
  • 19
  • 80
  • 150
0
votes
2 answers

Can't get JBox2d Testbed to work

I have followed this tutorial and the testbed launches, but nothing ever happens. The GUI appears but the tests never run, it just sits there. The testbed is launched from the driver class and you add the testbed test. Anyone else have this…
NJGUY
  • 2,045
  • 3
  • 23
  • 43
0
votes
1 answer

Why must Box2D use floating point values?

After taking a look at code using the JBox-2D engine, it is clear that float declarations are used very often: float x = 20.0f //<-- float FixtureDef fixDef = new FixtureDef(); fixDef.shape = shape; fixDef.density = 0.0f; //<--…
ylun.ca
  • 2,504
  • 7
  • 26
  • 47
0
votes
2 answers

What is the 'f' used for in JBox-2d?

It seems to be used in value declarations in the engine but the documentation of JBox-2D does not explain what this 'unit' is. Example: float x = 20.0f //<-- this 'f' FixtureDef fixDef = new FixtureDef(); fixDef.shape = shape; fixDef.density =…
ylun.ca
  • 2,504
  • 7
  • 26
  • 47
0
votes
1 answer

Jbox2D isSensor for NPC collision

I have a 2D side scrolling game that's kind of like a metroid-vania, I have some NPC's I want to add, and I want to simulate them in the world with gravity and such(they collide with the floors) but I don't want them to collide with the player.…
Snowdrama
  • 405
  • 1
  • 6
  • 17
0
votes
2 answers

Shaky unstable JBox2D bodies

Edit 2: http://youtu.be/KiCzUZ69gpA - as you can see in this video, the shaking effect is amplified when I also render some text for each body. Observe how the ground body (blue) shakes violently when each body has some text rendered near it, and…
corazza
  • 31,222
  • 37
  • 115
  • 186
0
votes
1 answer

JBox2D Coordinates Don't Match

Working on a Jbox2D program I created 2 objects a rectangle at (0,10) meters and 10 Meters Wide and 1 meter wide, and a Ball at (1,0) that has a radius of 0.5f Meters //in RectangleObject Class PolygonShape cs = new…
Snowdrama
  • 405
  • 1
  • 6
  • 17
0
votes
1 answer

Java, LibGDX, and JBox2d: Resizing a window while maintaining the aspect ratio of the objects being drawn

I am conducting a learning experiment with Java. I am attempting to create a simple "Megaman" style game using Java and the 3rd party API "LibGDX". I have obtained a rather solid understanding of the relationship between the OrthographicCamera…
0
votes
1 answer

java jbox2d swing draw and move shape

How do I draw a shape and then move with jbox2D and swing ? I can draw it but when I move, the old shape is displayed. thank you public class DrawShape extends DebugDraw { private Graphics graphics; public DrawShape(Graphics graphics) { …
0
votes
1 answer

JBox2d testbed rotate the world

how can i change the coordinate system of the testbed world output? Thanks. http://postimg.org/image/71d6fner5/ http://postimg.org/image/upx9oo0oh/ I decided the question. I'am override DebugDraw and set YFlip to false in…
Artur
  • 327
  • 2
  • 14
0
votes
2 answers

JBox2D - Drawing with DebugDraw

How do you draw elements with JBox2D? I'm fine using the DebugDraw, I just want to find a quick way to do this in Java since I haven't worked much with graphics. Do I need to use a Canvas? Or a JFrame? And how does the world know when I call…
Josh T
  • 564
  • 3
  • 12
0
votes
1 answer

Box2d body OnUpdate Function

I have two bodies(A,B). I want B follows A. I can change B position with setTransfrom() function to A position. But I have to change B's position in every frame rate. So I have to use something like contact listener. When I use normal object in…
immyth
  • 43
  • 9
0
votes
1 answer

Processing with JBox2d Hellow World issue

Using eclipse, I'm trying to write a simple hello world program in processing that simply draws a rectangle on the screen then has gravity drop it as seen in this Tutorial. The problem is that when I try to import the p5 package, it's not…
Brantley Blanchard
  • 1,208
  • 3
  • 14
  • 23
0
votes
1 answer

Knockback effect with top down graphics on box2d

I'm currently making a top down gfx actiong RPG on java, using jbox2d. Basically I want the enemies to recoil back after they get hit by the player (with top down graphics I don't have friction or gravity). I tried with restitution, applying impulse…
Epi
  • 682
  • 3
  • 10
  • 16
0
votes
1 answer

Apply linear impuls to pushed point - Box2D on Android

I would like to get a shape to move from middle bottom to the point I'm touching. Issue is to solve the angle (or degree?) to the touched point. float angle = ? float power = calculatePower(touchY); Vec2 impulse = new Vec2(angle, power); Vec2 point…
Jan-Terje Sørensen
  • 14,468
  • 8
  • 37
  • 37