Example #1
0
        static public void add_box(cpSpace space, int index, float size)
        {
            float mass = size * size / 100.0f;

            cpBody body = space.AddBody(new cpBody(mass, cp.MomentForBox(mass, size, size)));

            //	cpBody body = cpSpaceAddBody(space, cpBodyInit(&bodies[i], mass, cpMomentForBox(mass, size, size)));
            body.SetPosition(cpVect.cpvmult(cp.frand_unit_circle(), 180.0f));
            cpPolyShape shape = space.AddShape(cpPolyShape.BoxShape(body, size - bevel * 2f, size - bevel * 2f, 0f)) as cpPolyShape;

            shape.SetRadius(bevel);
            shape.SetElasticity(0.0f);
            shape.SetFriction(0.9f);
        }