protected override void Init() { base.Init(); var cubeTexture = new Texture("BoxDiffuse.jpg"); cubes = new Cube[PyramidHeight, PyramidHeight]; for (int z=0; z<PyramidHeight; z++) for (int x=0; x<PyramidHeight; x++) cubes[x, z] = new Cube(cubeTexture, new Vector3D( 1.1f*(x-(PyramidHeight)/2.0f), 0, 1.1f*z+2.55f)); for (int z = 0; z < PyramidHeight; z++) for (int x = 0; x < PyramidHeight - 1; x++) { var horizontalJoint = new PrismaticJoint(Entities.world3D, cubes[x, z].body, cubes[x+1, z].body, 1.1f, 1.1f); horizontalJoint.FixedAngleConstraint.Softness = 1; horizontalJoint.Activate(); if (z < PyramidHeight - 1) { var verticalJoint = new PrismaticJoint(Entities.world3D, cubes[x, z].body, cubes[x, z + 1].body, 1.1f, 1.1f); verticalJoint.FixedAngleConstraint.Softness = 1; verticalJoint.Activate(); } } }
public void Update(float timeDeltaInSeconds) { time += timeDeltaInSeconds; if (time > spawnTime) { time -= spawnTime; var newParticle = new Cube(cubeTexture, position); newParticle.body.ApplyImpulse(new JVector( -0.25f + 0.5f * (float)random.NextDouble(), -0.25f + 0.5f * (float)random.NextDouble(), 1)*15); particles.Add(newParticle); } foreach (var particle in particles) { particle.lifeTime += timeDeltaInSeconds; if (particle.lifeTime > maxLifeTime) { particle.Dispose(); particles.Remove(particle); break; } } }