Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Box2d + SFML  (Read 2209 times)

0 Members and 1 Guest are viewing this topic.

Roose Bolton of the Dreadfort

  • Full Member
  • ***
  • Posts: 113
  • Full-time Procrastinator, Part-time programmer.
    • View Profile
    • Personal Portfolio/Website/Blog
Box2d + SFML
« on: October 19, 2012, 12:22:53 pm »
Does anyone know of any Box2d + SFML samples/tutorials that give a nice introduction to the topic?

I'm hoping to implement some simple physics to my game but would like too see someone else implementation first!

Cheers boyos.
Trying so very hard to finish at-least one project.

Watch out for the RAII police, they will get you.

www.bantersaurus-games.com

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
Re: Box2d + SFML
« Reply #1 on: October 19, 2012, 01:05:16 pm »
There are many code pieces in the forum and the question has been ask several time, so the search function would seem like a useful feature after all... :P

You could take a look at the Eduard Engine by FRex that integrates Box2D (with some DebugDraw code in the same thread).
This tutorial seems like a good and often referenced source on how to use Box2D, but it's not SFML specific.

I think just by searching & reading you'll get quite a bit of information. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Box2d + SFML
« Reply #2 on: October 19, 2012, 04:33:40 pm »
I honestly have no idea what the people are asking for when they say box2d sfml integration or the like..?
I mean really: box2d the physics simulation -> has getPosition(), sfml the renderer -> has setPosition()..
Hmm..hmm.. what do we do? ;D
That debug draw is kind of crappy, I think I wrote new one. And all the integration there was is debug draw, collision and callback classes and lines of sprite.setPosition(ConvertVector(my_body->getPosition()));
Also don't get fooled by 'engine', this was just messing around a bit with sfml and box2d.
It probably could be extended. Especially thanks to call backs. There is EEUserData class that has methods CollidedWith and PartedWith that take pointer to EEUserData so collision callback class takes void pointer from fixture, cast it to eeuserdata and then give both the pointer of other data so they can decide what to do.(order does not matter, if there was any physical interaction, it'd have to be lazy assignment because callbacks happen when it's forbiden to modify the world).
« Last Edit: October 19, 2012, 04:48:11 pm by FRex »
Back to C++ gamedev with SFML in May 2023