private static void CreateBodies(World world, float worldSideLength, float metersPerBody, BodyStructureType bodyType) { // load the game world var tempWorld = new World(); RubeLoader.Load("data/testbodies.json", tempWorld); // settings const float MAX_LINEAR_VELOCITY = 20.0f; const float MAX_ANGULAR_VELOCITY = 1.5F; // add the specific body //const int COMPLEX_BODY_INDEX = 2; //const int C_BODY_INDEX = 1; //const int BOX_BODY_INDEX = 0; var worldRadius = worldSideLength / 2f; var selectedBodyIndex = (int)bodyType; //BOX_BODY_INDEX; for (var x = metersPerBody; x <= worldSideLength - metersPerBody; x += metersPerBody) { for (var y = metersPerBody; y <= worldSideLength - metersPerBody; y += metersPerBody) { var bodyDef = tempWorld.BodyList[selectedBodyIndex]; var body = bodyDef.DeepClone(world); body.Position = new Vector2(x - worldRadius, y - worldRadius); body.LinearVelocity = RandomGenerator.Vector2(MAX_LINEAR_VELOCITY); body.AngularVelocity = RandomGenerator.Float(-MAX_ANGULAR_VELOCITY, MAX_ANGULAR_VELOCITY); } } }
private RubeLoaderTest() { RubeLoader.Load("Data/rubegoldberg.json", this.World); }