Chipmunk questions - Printable Version +- iDevGames Forums (http://www.idevgames.com/forums) +-- Forum: Development Zone (/forum-3.html) +--- Forum: Game Programming Fundamentals (/forum-7.html) +--- Thread: Chipmunk questions (/thread-8057.html) Pages: 1 2 3 4 RE: How do I use an external library? - Skorche - Sep 3, 2010 05:56 AM I think you are a little confused. Chipmunk spaces are pretty much infinite. They fill up everything. "What are the window's center's coordinates in the space's coordinates?" Assuming that you draw the objects in the space in the window's coordinates, then the two coordinate systems are the same and the windows center is it's own coordinates. RE: How do I use an external library? - Miglu - Sep 3, 2010 06:01 AM Where is the space's origin? I could not find any method to change the origin. RE: How do I use an external library? - Skorche - Sep 3, 2010 08:45 AM It's absolute coordinates, the origin is always at (0,0). If you need to draw the origin somewhere else you need to set up your drawing transforms or offsets to do so. RE: How do I use an external library? - Miglu - Sep 3, 2010 01:42 PM When a body is moving, I have tried pressing the key that causes acceleration in the other direction. When its velocity is 0 and I unpress the key, the body's velocity returns to the direction that it was moving in, although the speed is lower. I have to do this at least two times to get the velocity to truly 0. How to correct this problem? Code: ```When the right arrow key is pressed: force.x = FORCE; In the update method: cpBodySetForce(body, force); cpBodyUpdateVelocity(body, cpvzero, 1, deltaTime); cpBodyUpdatePosition(body, deltaTime); cpSpaceStep(space, deltaTime);``` RE: How do I use an external library? - Skorche - Sep 3, 2010 02:35 PM Chipmunk calls cpBodyUpdateVelocity() and cpBodyUpdatePosition() for you. You don't need to call them yourself. RE: How do I use an external library? - Miglu - Sep 3, 2010 02:45 PM I removed them but still got the behavior. I also noticed that the body starts moving in the same direction even if I accelerate beyond 0 velocity in the opposite direction, although only for a small opposite velocity. Side question: if it calls them automatically, how does it know deltaTime? RE: Chipmunk questions - Skorche - Sep 3, 2010 04:26 PM Because you pass the delta time to cpSpaceStep() and it forwards it on. RE: Chipmunk questions - Miglu - Sep 4, 2010 03:58 AM I added cpBodyResetForces(body) before cpBodySetForce(body, force), but the problem persisted. Then I tried changing cpBodySetForce(body, force) to cpBodyApplyForce(body, force, cpvzero) but the behavior still persisted. Could you tell what is wrong with using Code: ```[circle moveBody]; cpBodyResetForces(body); cpBodyApplyForce(body, force, cpvzero); cpSpaceStep(space, deltaTime);``` to do a simple rigid body simulation. RE: Chipmunk questions - Skorche - Sep 4, 2010 10:08 AM Chipmunk only changes the velocity of things if you have gravity set or are applying forces or impulses to the body. I'm not quite sure what you are describing either. Can you make a video of it maybe? RE: Chipmunk questions - Miglu - Sep 4, 2010 12:46 PM I solved the problem. It was not with Chipmunk, but in the glTranslate method. Next question: In my application, two circle bodies do not collide when they touch. What is the problem? Code: ```In initialization:     cpInitChipmunk();     space = cpSpaceNew();     cpSpaceAddBody(space, circle1.body);     cpShape *shape = cpSpaceAddShape(space, cpCircleShapeNew(circle1.body, RADIUS*size.height, cpvzero));     cpSpaceAddBody(space, circle2.body);     cpShape *shape2 = cpSpaceAddShape(space, cpCircleShapeNew(circle2.body, RADIUS*size.height, cpvzero)); In update:     [circle1 moveCircle];     [circle2 moveCircle];     cpBodyResetForces(circle1.body);     cpBodyResetForces(circle2.body);     cpBodyApplyForce(circle1.body, circle.force, cpvzero);     cpBodyApplyForce(circle2.body, circle2.force, cpvzero);     cpSpaceStep(space, deltaTime);``` RE: Chipmunk questions - Miglu - Sep 5, 2010 11:14 AM Is it bad that I ask so many questions in these forums? RE: Chipmunk questions - AnotherJake - Sep 5, 2010 11:18 AM Nope. That's what the forums are for! Folks around here don't like to do the leg-work for other people though, so as long as it's obvious you're making an effort to solve your problems on your own first, feel free to ask as many questions as you wish. RE: Chipmunk questions - Miglu - Sep 5, 2010 11:57 AM I think that by including relevant code, people understand that I have made an effort to try to solve the problem. It is much better than including no code or including the entire project. Could you answer the question that I asked before the last post RE: Chipmunk questions - Skorche - Sep 5, 2010 12:08 PM I don't see anything wrong with the code that you posted. How are you initializing the bodies? RE: Chipmunk questions - Miglu - Sep 5, 2010 12:16 PM circle1.body = cpBodyNew(1, 0);