Giter Site home page Giter Site logo

Collision issues about sfml-tmxloader HOT 7 CLOSED

Elit3d avatar Elit3d commented on June 24, 2024
Collision issues

from sfml-tmxloader.

Comments (7)

jdmarsh avatar jdmarsh commented on June 24, 2024

If you're using SetPosition, it calls Move which edits the polypoints and causes collision issues, there is a bug for it here: #21

from sfml-tmxloader.

Elit3d avatar Elit3d commented on June 24, 2024

is there a way around this? been trying to get my player to collide with the walls but gave up as it wasn't recognizing it

from sfml-tmxloader.

jdmarsh avatar jdmarsh commented on June 24, 2024

You can comment out the lines where the polypoints are changed in MapObject::Move but even after I did this I was getting some different issues and I didn't want to waste lots of time debugging it.

I went the route of converting each MapObject into an sfml convex shape and wrapping it in my own class. You'll have to copy the MapObject::intersects and MapObject::contains methods to do collision with the convex shapes.

from sfml-tmxloader.

fallahn avatar fallahn commented on June 24, 2024

This is basically down to a badly designed MapObject class on my part. I'm aware of this and plan to rewrite it using the sf::Transformable class. As this will be likely an API breaking change it will be part of version 2 of the map loader (although I can't offer any estimation on when it's done, I only work on this as time allows). Version 2 can always be previewed via the 'next' branch of the repository (and already has many improvements) if you want to track its progress. For a work around in its current state, although it's a little more effort, the box2D utilities do correctly parse map objects, so the box2D collision detection system can be used. Box2D doesn't force you to use the physics part if you only wish to detect collisions - they can be handled by your own callbacks if you'd prefer (check out the box2D docs for this).

from sfml-tmxloader.

Elit3d avatar Elit3d commented on June 24, 2024

So I wouldn't need box2d in order to do this method?

from sfml-tmxloader.

fallahn avatar fallahn commented on June 24, 2024

You still need to link to box2D. Using the functions found in tmx2box2d.cpp you can then convert the map objects to box2D objects. Afterwards you can either let box2D use its physics, or you can supply callbacks to box2D to handle your own collisions.

from sfml-tmxloader.

fallahn avatar fallahn commented on June 24, 2024

I've pushed a potential fix for this to the 'next' branch, if anyone would like to try it and offer feedback / pull requests. I'll close this particular issue and point to #21 for further discussion

from sfml-tmxloader.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.