Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have used one polygon shape image (terrain)in my game its just like mountain and now i want to move the tanker on mountain path from one direction to other and then its turn on touching of the screne and move back and move like this continuously, i am not getting the method to move the tanker on slope(image) path in chipmunk spacemanager.

b.when collision detection happen like that if any bomb will fall on slope(image of mountain) then i want little damage on slope(image of mountain) like this video i want to please see this video for more details.

http://www.youtube.com/watch?v=vleq3Wa_jZs

i have used this code but my object(tanker) is following terrain path with rotation i want to just move like tanker moving and follow terrain path.

-(void)AddWheel
{
    cpShape *localPlayerShape;
    cpCCSprite *localPlayerSprite;

    localPlayerShape = [mySpaceManager  addCircleAt:[self GetStartingWheelPosition] mass:2 radius:7];
    localPlayerSprite = [cpCCSprite spriteWithFile:@"enemy1.png"];

    localPlayerSprite.shape=localPlayerShape;

    localPlayerSprite.shape->group=kItemIsPartOfTheTankGroup;
    localPlayerSprite.shape->collision_type=kItemIsPartOfTheTankGroup;

    localPlayerSprite.shape->u=4.5;

    localPlayerSprite.tag=100;

    [mySpriteLayer addChild:localPlayerSprite z:15];
}

Thank waiting for you all reply .

share|improve this question

2 Answers 2

If you're trying to clone the game in the video, I wouldn't use real physics at all. Use a 1-dimensional height map for the ground -- that way you can just modify the data in the height map when a bomb hits the ground, rather than adding new vertices to a polygon.

When the tanks move, rotate them so that their treads are lined up with the slope of the ground and just move them horizontally, making sure that they're always at the same height as the ground underneath them. You can make them move slower or faster depending on the slope.

I think a physics engine is overkill for what you're trying to do. :)

Edit:

If you need a quick hack to just set the position and angle of a body, use cpBodySetPos and cpBodySetAngle. Note that you're essentially not using the physics engine at all if you do that. :)

share|improve this answer
    
+1 I completely agree, for the example given, you only really need to know the height of the terrain at each pixel column, i.e. a 1D heightmap. Unless you need more complexity in your maps such as in Worms. –  David Gouveia Mar 1 '12 at 5:18

To answer your first question: You need to apply a force or an impulse on your tank. You cannot directly "move" an object in chipmunk.

void cpBodyApplyForce(cpBody *body, const cpVect f, const cpVect r) 
void cpBodyApplyImpulse(cpBody *body, const cpVect j, const cpVect r)

To answer your second question: You need to deform your polygon shape according to the impact of the bomb. (I would stay away from this problem and concentrate on the first for starters.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.