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

Author Topic: SFML + Box2D  (Read 11752 times)

0 Members and 1 Guest are viewing this topic.

krrice

  • Newbie
  • *
  • Posts: 26
    • View Profile
SFML + Box2D
« on: April 06, 2013, 02:49:04 am »
I was just wondering how may people in the forum use Box2D for physics? I have been learning C++ , Allegro for about 1 1/2 years and sfml 2 for about 6 months. Just wanted some kind of idea on weather I should learn to code my own or use an existing engine like Box2D? Any pointers will be appreciated.

arbitergoten

  • Guest
Re: SFML + Box2D
« Reply #1 on: April 06, 2013, 03:58:17 am »
sure i will give you a pointer :)  0x2A65923A

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: SFML + Box2D
« Reply #2 on: April 06, 2013, 04:49:35 am »
sure i will give you a pointer :)  0x2A65923A
Did you now really register to just write this post? >:(

It really all depends on what your goal exactly is. Physics is a huge topic and goes way beyond crunching some number with C++ code, but if you don't really have much going on in your game, a self-baked solution might work as well and fit way better into your system.
If however you write a 2D game with quite a bit of collisions going on and maybe even some more complicated ones (not just AABB or similar), then you might save yourself a lot of time by using an existing library, but maybe at the cost of having to readjust your code to work with e.g. Box2D or alternatively write a wrapper to abstract the library.

But unless you really know what you want to do and can guess its size, it's not really possible to make a final decision. ;)
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: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: SFML + Box2D
« Reply #3 on: April 06, 2013, 05:00:52 am »
Quote
Did you now really register to just write this post? >:(
I registered to give someone 1.6 tutorial they couldn't recall the name of which I myself didn't even agree with or learned much from. At least he does what he loves. :P

Ok, this may sound hostile(I'm not) but: you will not outperform nor outfeature Box2D, other engine might suit you better or even be better, but you will not ever do it yourself. Catto has years of experience and Box2D is tweaked crazily for performance and now blowing physics up, there is even a huge comment discussing selected collision method somewhere in source code. You will probably get lost when friction, inertia, damping and rotation comes into equation and/or go with n^2 complexity with your AABB. Box2D is crazily packed with features really.
I'm pretty sure most of the games that use physics in flash use it judging by the sole amount of posts in it's Flash port forum(over 25% of all of it). LOVE(Lua game engine) uses it, cocos2d(obj C, popular iDevices game engine/framework) uses it, it has ports to js, flash and many more. Silly Angry Birds uses it. I'm not even sure why it is so popular, it just is. I even seen advert while looking through programming jobs once for iDevices game dev, that specifically said 'Box2D experience'.
« Last Edit: April 06, 2013, 05:02:49 am by FRex »
Back to C++ gamedev with SFML in May 2023

arbitergoten

  • Guest
Re: SFML + Box2D
« Reply #4 on: April 06, 2013, 06:15:35 am »
Did you now really register to just write this post? >:(

nope lol i registered a while ago but this was my first post. Sorry i just had to do it ;D

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: SFML + Box2D
« Reply #5 on: April 06, 2013, 10:46:08 am »
I registered to give someone 1.6 tutorial they couldn't recall the name of which I myself didn't even agree with or learned much from. At least he does what he loves. :P
Well that was at least helpful in some way, posting without even caring about the topic, but for the lulz is considered trolling...

you will not outperform nor outfeature Box2D...
Yes, if you try to copy Box2D's functionalities, then you won't succeed, but as I mentioned before, the question is, if you want/need to copy Box2D. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Sui

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
    • http://www.suisoft.co.uk/
Re: SFML + Box2D
« Reply #6 on: April 06, 2013, 01:05:31 pm »
I'm with exploiter. I've built my own very basic physics for my games so far, but wouldn't consider tackling a physics-based or very physics heavy game that way. I'm decent (although not awsome) at maths but the tougher physics algorithms make my head hurt.

I want to try out Box2D myself at some point and create a little demo game.

If it's good enough for Angry Birds:
http://techcrunch.com/2011/02/28/creator-of-angry-birds-physics-engine-calls-out-rovio-for-not-giving-him-credit/

Can't ask for much more usability testing than via a game that's sold squillions of copies across the known universe.
Gary Marples, Developer of games and other stuff.
www.suisoft.co.uk/games/BlogTwitter

krrice

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: SFML + Box2D
« Reply #7 on: April 09, 2013, 08:15:30 pm »
Thanks for the info everyone. What I get from the replies is that most of you like Box2D but don't really use it for your in game physics.

Halsys

  • Jr. Member
  • **
  • Posts: 66
  • Halsys like Hal.sys
    • View Profile
    • Email
Re: SFML + Box2D
« Reply #8 on: April 10, 2013, 10:10:46 am »
I am using Box2D for my game, its a ambitious platformer... I plan on making it a really big game.
Its called Project Red, You play as a prototype robot called "Red" who figured out he can think freely and he finds out all the bad things the corporations who made him did and he wants to be free and make things right. So I have been messing with Box2D for about over 5 months now working on my game. If you want help working Box2D with SFML, I can help you on that.. PM me anytime.

Also...
Things you might want to work on with Box2D is a nice level loading system and getting Debug draw working as soon as possible. I use XML's to load my maps and assets, it makes setting points with Box2D very easy and the development process is going to get even faster as soon as I get a Level Editor up and working.  Whats even more awesome is to make the level editor and the actual game the same program so I can flop between dev and play on command. Which is something I would recommend you do too if you plan on doing some heavy duty work.

But what I really hate about Box2D is the lack of documentation or tutorials... All the good stuff I find are on http://www.iforce2d.net/, Also no one actually tells you how to get around Time steps without telling you to do fixed time steps of 60 hz and a Vertical sync... And that's really not professional if you want to make great games. I managed to get around that, and you can ask for it if you want to see.
If you notice I put "....", in my sentences way too much... I'm sorry.

Halsys

  • Jr. Member
  • **
  • Posts: 66
  • Halsys like Hal.sys
    • View Profile
    • Email
Re: SFML + Box2D
« Reply #9 on: April 11, 2013, 07:54:47 am »
kkrice asked me to make a simple Demo with with Box2D and SFML to demonstrate how it works.
So I thought it would be nice to dump the code here so everyone can see it to figure out how to use SFML and Box2D together or they need a head start for a awesome platformer game. I even added a couple extras based off my game, I want to leave some credit to iforce2D, Some code is based on some of his, Which I take no credit for. Its 471 lines of code and you need SFML 2.0 and The latest build of Box2D(2.2.1). You can open the debug drawing "Feature" with F3 so you can see how accurate it is or how wonderful my coding is. Also the DebugDraw is a modified version of the Test bed's Debug Draw from Box2D.

Its a extremely simple platformer with 3 tiles and 1 player. Your free to make it part of your game, I don't care what you do with it as long as you leave some credit for me and the people whose code is in there.

https://legacy.sfmluploads.org/file/175

Its a Code blocks project with one cpp file and I may have included SFML dll's, I'm sorry about the extra downloaded junk... I kinda rushed it. Weird thing is I had the bright notion to remove the obj folder but not the DLL's... So again... sorry, my bad.

Anyway, Enjoy the code.
If you notice I put "....", in my sentences way too much... I'm sorry.

 

anything