Page 1 of 1

Is this possibe in ChipMunk?

Posted: Sat Jun 21, 2008 11:36 am
by rico
Hello, I've only recently downloaded Chipmunk - Thank you very much Slembcke! - and Brucey (I am using the Blitzmax module). I have looked at the command and played around with some of the demos. I have an idea of a game I wish to write using ChipMunk and I was wondering if it is possible to do the following things in ChipMunk and also how they can be implemeted. I am a beginner so I apologise if I have asked anything obvious.

These are all to be implemeted in a 2d platform game.

- I want to have my main character, and possibly some enemy characters represented by a polygon outline. Maybe even a box. However currently boxes tip when they reach the edge of platforms I want my box to not rotate at all and also to be able to stay on the platform until the last corner is no longer in contact with the platform. How Can I make a box which will not rotate? This is also good because I do not want my main character to tip up at an angle when going up slopes. I can also think of other features in the game which could use non-rotating boxes. I have thought of using a circle but these fall off platforms early too! (when you walk off a platform i want my man to stay on the platform until the last part of him is no longer in contact with the platform)

- I want to have automatic doors which open by sliding into the walls. Hence they are like a thin rectangle which gets shorter each frame (while they are opening). How can I implement this in Chipmunk? (i don't need code just an idea of what technique to use)

- I would like to do moving platforms (like all good platform games :)). What commands should I use to do these. Won't these rotate round when something lands on them? How can I fix them in place so they don't rotate but can still move?

I really appreciate any help. Thank you very much - Rico

Re: Is this possibe in ChipMunk?

Posted: Sat Jun 21, 2008 2:11 pm
by Michael Buckley
rico wrote:- I want to have my main character, and possibly some enemy characters represented by a polygon outline. Maybe even a box. However currently boxes tip when they reach the edge of platforms I want my box to not rotate at all and also to be able to stay on the platform until the last corner is no longer in contact with the platform. How Can I make a box which will not rotate? This is also good because I do not want my main character to tip up at an angle when going up slopes. I can also think of other features in the game which could use non-rotating boxes. I have thought of using a circle but these fall off platforms early too! (when you walk off a platform i want my man to stay on the platform until the last part of him is no longer in contact with the platform)
You can achieve this by setting the moment of inertia of a cpBody (the moment of inertia is the second parameter to cpBodyNew()) to INFINITY. The object will then never rotate ever.
rico wrote:- I want to have automatic doors which open by sliding into the walls. Hence they are like a thin rectangle which gets shorter each frame (while they are opening). How can I implement this in Chipmunk? (i don't need code just an idea of what technique to use)
You mean like the boss doors in Mega Man? It's generally not good to change the collision bounds of an object, so my best advice would be to make it slide up into the wall above it. You'll have to make sure that the wall and the door don't collide. You can do that by putting them in different collision layers or using a collision pair function.
rico wrote:- I would like to do moving platforms (like all good platform games :)). What commands should I use to do these. Won't these rotate round when something lands on them? How can I fix them in place so they don't rotate but can still move?
Again, by setting the moment of inertia to INFINITY, it's not going to rotate, and you can still move the object. However, it's still going to be affected by other bodies in the same space, so if your character lands on top of it, it's going to start moving downward. for this, you're going to have to set the platform's mass (which is the first parameter to cpBodyNew()) to INFINITY as well. Then, for each frame, you're going to have to manually calculate the position, and velocity manually each frame. I think it should be fine if you leave the acceleration at 0, as long as the platform has a constant velocity, but that might cause some problems when the platform changes direction. You'll just have to test it and see.

Re: Is this possibe in ChipMunk?

Posted: Sat Jun 21, 2008 4:09 pm
by slembcke
Um, go team. That's pretty much exactly what I would have said.

Re: Is this possibe in ChipMunk?

Posted: Thu Jun 26, 2008 2:51 pm
by rico
Ok - Thank you very much for your help. I like your solution to the sliding doors. I suppose I only have to draw part of the door to the screen, so I can make it look like its going into the wall anyway.
I will use your ideas for the moving platforms too, and see what happens, hopefully it will work, I'm sure other people must have managed it somehow! I haven't played any of the Megaman games, people are always saying they are rock hard. I was playing games in that period, so I feel a bit ashamed I've never tried them.
Thanks again. Bye! 8-)