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

Author Topic: simple SFML + Box2D test project  (Read 10047 times)

0 Members and 1 Guest are viewing this topic.

bobasaurus

  • Newbie
  • *
  • Posts: 9
    • View Profile
simple SFML + Box2D test project
« on: September 08, 2010, 07:17:42 am »
I made a simple test project with SFML and Box2D.  My entire goal was "make a box and bonk into some stuff," so I guess I've succeeded.  Here is the (windows exe) download to play with, and source:

windows binary/exe:  https://sites.google.com/site/box2dsfmlfiles/box2dsfmlfiles/sfml_test.zip

source code:  https://sites.google.com/site/box2dsfmlfiles/box2dsfmlfiles/sfml_testsource.zip

I made a stupid blog about it, thinking that I'll make some more examples to share in the future:
http://box2dsfmlfun.blogspot.com/

This is a really basic project, but hopefully I can build on it and learn some more (physics sims are fun :).

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
simple SFML + Box2D test project
« Reply #1 on: September 08, 2010, 08:56:42 am »
It's great to have people using blogs, I like to read this kind of stuff.  :D I will follow it (I work with Box2D too).

WitchD0ctor

  • Full Member
  • ***
  • Posts: 100
    • View Profile
    • http://www.teleforce-blogspot.com
simple SFML + Box2D test project
« Reply #2 on: September 08, 2010, 01:18:48 pm »
neat, i plan on adding box2d to my game sometime soon, this will definitely help ease the transition

thanks!
John Carmack can Divide by zer0.

TheMagicNumber

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
simple SFML + Box2D test project
« Reply #3 on: September 08, 2010, 01:36:42 pm »
Maybe gravity changes should un-freeze everything. :D

bobasaurus

  • Newbie
  • *
  • Posts: 9
    • View Profile
simple SFML + Box2D test project
« Reply #4 on: September 08, 2010, 05:31:56 pm »
Yeah, I need to figure out how to un-freeze objects that come to rest so gravity will apply... I suppose I could give them a small force to "nudge" them into falling, but there should be a better way.

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
simple SFML + Box2D test project
« Reply #5 on: September 08, 2010, 07:25:35 pm »
Use the WakeUp() method of b2Body. ;)
(Chapter 10, §Exploring the world in the Box2D Manual)

bobasaurus

  • Newbie
  • *
  • Posts: 9
    • View Profile
simple SFML + Box2D test project
« Reply #6 on: September 08, 2010, 09:23:48 pm »
Nice tip there... I'll add it in :)  I need to read all the way through the docs to fine these neat tidbits.

bobasaurus

  • Newbie
  • *
  • Posts: 9
    • View Profile
simple SFML + Box2D test project
« Reply #7 on: September 12, 2010, 08:42:50 pm »
I updated the first set of code to wake up the blocks on gravity changes: http://box2dsfmlfun.blogspot.com/2010/09/update-to-test-1.html

I also created a new SFML+Box2D test project where I draw an arch using the polar equation of an ellipse: http://box2dsfmlfun.blogspot.com/2010/09/box2d-with-sfml-test-2-arch.html

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
simple SFML + Box2D test project
« Reply #8 on: September 13, 2010, 02:12:46 am »
Very nice sample, thanks a lot for sharing! However, I recommend you start using a version control system. That way, you will not have to post updated versions of your stuff but you simply commit to an online repo and other people will be notified.

Personally, I use github for that.

bobasaurus

  • Newbie
  • *
  • Posts: 9
    • View Profile
simple SFML + Box2D test project
« Reply #9 on: September 13, 2010, 02:15:45 am »
I use subversion locally (with the awesome tortoise svn client), but I like to just zip up the project dir for the examples since it's easy and doesn't require users to have the right version control client just to get the files.

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
simple SFML + Box2D test project
« Reply #10 on: September 13, 2010, 03:04:10 am »
Most developers will have the most common vcs at hand. I don't think that is an issue here. However, don't you think that a simple svn up is preferred to going into this thread to see whether you changed something? Also, to see your changes with zips, I need to extract both trees next to each other and run a recursive diff against both. If you used a vcs I could just use svn log and svn diff to see the changes.

bobasaurus

  • Newbie
  • *
  • Posts: 9
    • View Profile
simple SFML + Box2D test project
« Reply #11 on: September 13, 2010, 03:23:58 am »
True enough.  I'll look into github.  Git seems to be growing in popularity, though I'm not too familiar with it.  Can't be too far off from svn, I guess.

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
simple SFML + Box2D test project
« Reply #12 on: September 13, 2010, 01:36:07 pm »
It's quite simple. With git, you only commit to local history (unlike svn) and to exchange your stuff with others you have to pull/push your history and changes. Apart from that, you will find many analogies. However, git is a lot faster than svn because all operations are done locally.

Looking forward to your repo!

Hugo

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
simple SFML + Box2D test project
« Reply #13 on: September 18, 2010, 04:28:15 pm »
I like ur name bobasaurus

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
simple SFML + Box2D test project
« Reply #14 on: October 23, 2010, 12:57:40 am »
I went ahead and added this project to my Github: http://github.com/svenstaro/physics-playground

I also cleaned it up a bit and made it sfml2 compatible. Enjoy, all additions are released under the original license (zlib).