Im using Box2D and Slick2D and im running into the issue pictured above, the objects are colliding properly but when drawn are not matching visually. I have a rectangle object class that contains
private Body body;
private float width;
private float height;
and I generate the PolygonShape like this:
public RectangleObject(float setX, float setY,float width, float height, BodyType setType){
bd = new BodyDef();
cs = new PolygonShape();
cs.setAsBox(width/2, height/2);//knowing that it uses "half-width" and "half-height"
this.width = width;
this.height = height;
//...
Similarly I generate the CircleShape like thus:
public CircleObject(float setX, float setY,float radius,BodyType setType){
bd = new BodyDef();
cs = new CircleShape();
bd.position.set(setX, setY);
cs.m_radius = radius;
this.radius = radius;
this.diameter = radius*2; //this is used later to draw the circle.
//...
And then I render the 2 like thus:
g.drawRect(platform.getX()-(platform.getWidth()/2f), platform.getY()-(platform.getHeight()/2f), platform.getWidth(), platform.getHeight());
g.drawOval(ball.getX()-ball.getRadius(),ball.getY()-ball.getRadius(),ball.getDiameter(),ball.getDiameter());
Everything works great and the 2 collide almost perfectly except they seem to have a gap in between them. I added more circles, and the CIRCLES dont have this issue.
so I think its a rendering issue on the side of the Rectangle. anyone have any insight as to why they might do this?