The only that is keeping my from using the library atm is that there is no in detail documentation like an article explaining how to begin with adding chipmunk to my existing Code.
I hope this gets adressed! I have looked into the docs and samples, but I could not find any good place to start reading and what I did read was not good enough to get me an idea of the flow of the program and how things are put together.
No Flame, just feedback.
regards
Step by Step Tutorial/Article?
-
- Posts: 4
- Joined: Mon Apr 11, 2011 3:28 pm
- Contact:
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: Step by Step Tutorial/Article?
No, it's definitely a fair complaint. Writing a beginner's tutorial is definitely on the giant "list of things that I really need to do", but has never gotten done. It's hard to prioritize everything.
The simplest example I have is the "Simple" demo in the Chipmunk Demo application:
http://code.google.com/p/chipmunk-physi ... o/Simple.c
It is a little out of date and some of the comments need to be updated. Like the part about adding the ground as a static shape is not necessary anymore. Chipmunk knows it should be a static shape because you are attaching it to a static body.
The part that is missing from the "Simple" demo is how to use Chipmunk from your own code. It uses the demo debug drawing code which just magically draws all the collision detection shapes in a space. In a real game you have basically two options:
The simplest example I have is the "Simple" demo in the Chipmunk Demo application:
http://code.google.com/p/chipmunk-physi ... o/Simple.c
It is a little out of date and some of the comments need to be updated. Like the part about adding the ground as a static shape is not necessary anymore. Chipmunk knows it should be a static shape because you are attaching it to a static body.
The part that is missing from the "Simple" demo is how to use Chipmunk from your own code. It uses the demo debug drawing code which just magically draws all the collision detection shapes in a space. In a real game you have basically two options:
- The recommended way: In your graphics code, keep a reference to the cpBody that the graphic you are drawing is attached to. Use the position and rotation of the body to draw the graphics. If you are using something like OpenGL for drawing, you can make a transformation matrix easily from a rigid body: http://files.slembcke.net/chipmunk/rele ... #transform
- Iterate the bodies in a space and use the 'data' pointer on them to hold a reference to your sprite or game object. Copy the position and rotation of the rigid body to the sprite. A lot of people do it, but I don't recommend doing things this way because it means that every single object needs to have its transform updated in the same way. This often leads people to use the data pointer exclusively for sprites and then they find themselves in a corner when they need a reference to something else in a callback.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 4
- Joined: Mon Apr 11, 2011 3:28 pm
- Contact:
Re: Step by Step Tutorial/Article?
Thanks for your reply.
I am all new to this physics stuff in game programming and I really have no clue how to begin.
I have my own library and my class BoundingBox. It has vertices and matrice-manipulation functions for rotating and translating etc. Adding a cpBody should be not too hard from what you say, once I understood the whole concept
.
I have looked at simple.c and it gave me some clues, but still not really comfortable.
I try to dig through it.
I am all new to this physics stuff in game programming and I really have no clue how to begin.
I have my own library and my class BoundingBox. It has vertices and matrice-manipulation functions for rotating and translating etc. Adding a cpBody should be not too hard from what you say, once I understood the whole concept

I have looked at simple.c and it gave me some clues, but still not really comfortable.
I try to dig through it.
-
- Posts: 2
- Joined: Sat Apr 16, 2011 7:12 pm
- Contact:
Re: Step by Step Tutorial/Article?
I have to agree with the original poster. I am brand new to game programming and physics and Chipmunk with Ruby and Gosu looks awesome to me. Knowing I can also use Chipmunk with Obj-C is a real selling point. However I can't figure out some simple things with it because there is no explanation for beginners anywhere. For example:
So far I have a player and a ball on a 2d Top-Down field and they collide. My problem right now is that I want my player to be a square.
I sucked at Math in high school and that was way too many years ago to think about. The documentation for Chipmunk says this about drawing a Polygon:
# Create a poly collision shape attached to the given body at
# the given offset with the given vertexes. _verts_ must be an
# Array of CP::Vect with a counterclockwise winding.
def initialize(body, verts, offset); end
I have this code to get my polygon right now:
verts = Array.new
verts.push(CP::Vec2.new(-32,32))
verts.push(CP::Vec2.new(32,32))
verts.push(CP::Vec2.new(0,-32))
verts.push(CP::Vec2.new(-32,0))
@shape = CP::Shape::Poly.new(@body, verts, CP::Vec2.new(0,0))
That ends up giving me a shape attached to my square png, but it appears as if 0,0 is the top, left corner of the image and the actual Polygon starts even farther to the top, left of the image.
So I assumed I should set the "Offset" to half of my width of my Polygon but that doesn't give me the right outcome.
I am sure that for most people on here this is elementary. But I am still in the elementary when it comes to game dev.
Can someone explain this to me please?
So far I have a player and a ball on a 2d Top-Down field and they collide. My problem right now is that I want my player to be a square.
I sucked at Math in high school and that was way too many years ago to think about. The documentation for Chipmunk says this about drawing a Polygon:
# Create a poly collision shape attached to the given body at
# the given offset with the given vertexes. _verts_ must be an
# Array of CP::Vect with a counterclockwise winding.
def initialize(body, verts, offset); end
I have this code to get my polygon right now:
verts = Array.new
verts.push(CP::Vec2.new(-32,32))
verts.push(CP::Vec2.new(32,32))
verts.push(CP::Vec2.new(0,-32))
verts.push(CP::Vec2.new(-32,0))
@shape = CP::Shape::Poly.new(@body, verts, CP::Vec2.new(0,0))
That ends up giving me a shape attached to my square png, but it appears as if 0,0 is the top, left corner of the image and the actual Polygon starts even farther to the top, left of the image.
So I assumed I should set the "Offset" to half of my width of my Polygon but that doesn't give me the right outcome.
I am sure that for most people on here this is elementary. But I am still in the elementary when it comes to game dev.
Can someone explain this to me please?
Who is online
Users browsing this forum: No registered users and 21 guests