Physics in SDL

Hi,
does somebody knows a good tutorial or some URL on physics (vectors etc.) which
is used with SDL?

dekyco

What kind of physics? Physics doesn’t benefit from SDL, except for
visualization and maybe simple threads and the portable atomic operations in
SDL 1.3.
For game physics, you’d start with the math. The basics like vectors,
forces, and such are covered by intro physics courses, material for which
can be found online. Calculus and linear algebra should cover all of the
basic math you need. You can search around for lessons on linear algebra,
multivariate calculus, and differential equations to round out the advanced
math. If you’re interested in a larger solution, a lot of people use Box2D
in their games as a physics engine. It seems to work well. Some people and
even big companies use Bullet for 3D game physics. If you want to implement
simple collisions, you might look up the “Separating Axis Theorem” and
"Rigid Body Dynamics". There’s some physics material on Gaffer on Games (
http://gafferongames.com/) and Chris Hecker’s site (
http://chrishecker.com/Category:Physics).

For real physics, if you already know all that math and numerical methods
(numerical integration and discretization), you’d want to look into
libraries like Lapack, PETSc, OpenMP, and MPI. I kinda doubt that’s what
you mean though :slight_smile:

If you need any further help, just ask.

Jonny DOn Fri, Mar 26, 2010 at 10:15 AM, dekyco wrote:

Hi,
does somebody knows a good tutorial or some URL on physics (vectors etc.)
which
is used with SDL?

dekyco


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Thank you Jonny,

do you know for some good resources on using Box2D with SDL?

No, I haven’t looked, but Box2D is popular enough that there are probably
some great ones out there. I’ve used Box2D only enough to try it out. Your
game objects will probably have both SDL (SDL_Surface*, etc.) and Box2D
(b2Body*, etc.) structures in them. You’d update the physics each logic
frame with Box2D’s stuff (like b2World::Step()) and draw the scene each draw
frame (SDL_BlitSurface(), SDL_Flip(), etc.).

Jonny DOn Sat, Mar 27, 2010 at 2:10 PM, dekyco wrote:

Thank you Jonny,

do you know for some good resources on using Box2D with SDL?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

If you’re one of those C purists, you may want to look into using chipmunk
physics (if you’re using SDL in C), but I would only recommend it if you
can’t find anything on Box2d - chipmunk has a serious lack of documentation.On Sat, Mar 27, 2010 at 2:28 PM, Jonathan Dearborn wrote:

No, I haven’t looked, but Box2D is popular enough that there are probably
some great ones out there. I’ve used Box2D only enough to try it out. Your
game objects will probably have both SDL (SDL_Surface*, etc.) and Box2D
(b2Body*, etc.) structures in them. You’d update the physics each logic
frame with Box2D’s stuff (like b2World::Step()) and draw the scene each draw
frame (SDL_BlitSurface(), SDL_Flip(), etc.).

Jonny D

On Sat, Mar 27, 2010 at 2:10 PM, dekyco wrote:

Thank you Jonny,

do you know for some good resources on using Box2D with SDL?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

If you’re one of those C purists, you may want to look into using
chipmunk physics (if you’re using SDL in C), but I would only
recommend it if you can’t find anything on Box2d - chipmunk has a
serious lack of documentation.

ODE is also a C physics engine, or rather, it’s written in C++ but its
interface is C functions and C structs. It’s BSD licensed. As far as I
know, the World of Goo game uses ODE as its physics engine and SDL for
the graphics front-end.

http://www.ode.org

ZoltanOn Sat, 27 Mar 2010 15:43:39 -0400 Alex Barry <alex.barry at gmail.com> wrote:

Jonny thank you very much,

do you have some piece of code which I can install into program becouse this is pretty confusing to me. Where exactly in class (for example level class) I need to set up this b2World object and such (suppose in constructor of the level),to get a working example in SDL. It is unclear to me what b2 objects going where in game loop - I understand this Step() method falls somewhere in the logic() part of the loop,rendering is done in render() part etc.

Just need some working demo,one object bouncing around maybe using some controls,using physics/gravity/collision,to get this thing going. Can’t find a minimal example of this (SDL/Box2D) on the google or elsewhere for some reason. Library archive contains only examples using freeglut for windowing/input/render.

dekyco

Here’s what I have left from when I tried it out:
code.bluedinosaurs.com/open/Box2dTest.zip

It’s quite a mess and there’s just a project file for Code::Blocks and a
binary for Ubuntu. It requires Sprig, includes an old version of NFont, and
uses a silly List class. This code represents the limit of my experience
and knowledge of Box2d. Some day I’m sure I’ll clean it up (pressure speeds
this process up as well ;).

Jonny DOn Mon, Mar 29, 2010 at 9:34 AM, dekyco wrote:

Jonny thank you very much,

do you have some piece of code which I can install into program becouse
this is pretty confusing to me. Where exactly in class (for example level
class) I need to set up this b2World object and such (suppose in constructor
of the level),to get a working example in SDL. It is unclear to me what b2
objects going where in game loop - I understand this Step() method falls
somewhere in the logic() part of the loop,rendering is done in render() part
etc.

Just need some working demo,one object bouncing around maybe using some
controls,using physics/gravity/collision,to get this thing going. Can’t find
a minimal example of this (SDL/Box2D) on the google or elsewhere for some
reason. Library archive contains only examples using freeglut for
windowing/input/render.

dekyco


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org