Slick Forums

Discuss the Slick 2D Library
It is currently Fri Sep 20, 2019 3:07 am

All times are UTC

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Boxes cutting corners
PostPosted: Mon Oct 29, 2012 5:31 pm 

Joined: Mon Oct 29, 2012 5:25 pm
Posts: 3
I'm using Slick and Phys2d to make a 2D platforming game. I'm using Phys2d bodies and Slick images in tandem to create entities, platforms, etc. My problem is, it seems like the bodies are cutting corners. This is especially an issue with gravity, because the player seems to slide off the edge of the platform if he gets too close. Consider this screenshot:
This is the source code:
import org.newdawn.slick.*;
import net.phys2d.raw.*;
import net.phys2d.raw.shapes.*;
import net.phys2d.math.*;

public class MainTest extends BasicGame
   Image box1, box2;
   Body body1, body2;
   World world;
   public MainTest()
    public void init(GameContainer gc)
       try {
          box1 = new Image("img/box1.png");
          box2 = new Image("img/box2.png");
       catch(SlickException e) {
       body1 = new Body(new Box(40, 40), 100);
       body2 = new StaticBody(new Box(200, 40));
       body1.setPosition(100, 100);
       body2.setPosition(200, 200);
       world = new World(new Vector2f(0, 0), 100);
    public void update(GameContainer gc, int delta)
          body1.adjustPosition(new Vector2f(-0.25f * delta, 0));
          body1.adjustPosition(new Vector2f(0.25f * delta, 0));
          body1.adjustPosition(new Vector2f(0, -0.25f * delta));
          body1.adjustPosition(new Vector2f(0, 0.25f * delta));
    public void render(GameContainer gc, Graphics g)
          throws SlickException
       box1.draw(body1.getPosition().getX() - 20, body1.getPosition().getY() - 20);
       box2.draw(body2.getPosition().getX() - 100, body2.getPosition().getY() - 20);
    public static void main(String[] args) throws SlickException
       AppGameContainer app =
         new AppGameContainer(new MainTest());

       app.setDisplayMode(800, 600, false);

Is there a way to stop these boxes from cutting corners?

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 4 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group