Esempio n. 1
0
 public void Draw(Camera camera, Model baseModel)
 {
     foreach (ModelMesh mesh in model.Meshes)
     {
         foreach (BasicEffect be in mesh.Effects)
         {
             be.EnableDefaultLighting();
             if (mesh.Name == "Box01")
             {
                 be.World = baseMatrix[mesh.ParentBone.Index] *
                     (Matrix.CreateTranslation(position) * scale) * rotation;
                 //world = world * scale;
                 //world = Matrix.Transform(world,scale);
                 //world = Vector3.Transform(new Vector3(2f, 0f, 0f), world);
             }
             else
                 //TODO set solution here
                 be.World = baseMatrix[mesh.ParentBone.Index] * Matrix.CreateTranslation(position) *
                     scale * rotation;
             be.View = camera.view;
             be.Projection = camera.projection;
         }
         mesh.Draw();
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        protected override void Initialize()
        {
            fixedBall = new Ball(1f);
            fixedBall.Texture = Content.Load<Texture2D>(@"basic_material");
            fixedBall.Position = new Vector3(0f, 0, 0f);

            ball = new Ball(0.3f);
            ball.Texture = Content.Load<Texture2D>(@"basic_material");
            ball.Position = new Vector3(0f, -2f, 0f);

            crate = new Crate(new Vector3(0.07f, 0.05f, 0.05f));
            crate.Position = new Vector3(0.3f, 5f, 0.20f);
            crate.Mass = 10;

            cg = new ContactGenerator();
            cg.AddBody(fixedBall);
            cg.AddBody(ball);
            cg.AddBody(crate);

            fixedBall.model = Content.Load<Model>(@"ball");
            ball.model = fixedBall.model;
            camera = new Camera(this, new Vector3(0, 0, 10f),
                Vector3.Zero, Vector3.Up);
            Components.Add(camera);
            g = new Gravity(new Vector3(0f, -10f, 0f));

            fixedBall.InverseMass = 0;
            fixedBall.InverseInertiaTensor = new Matrix();
            ball.Mass = 1f;
            sp = new Spring(fixedBall, ball, 3f, 2f, 0.995f, Vector3.Zero, new Vector3(0.5f, 0.5f, 0.5f));
            base.Initialize();
        }
Esempio n. 3
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        protected override void Initialize()
        {
            fixedCrate = new Crate(new Vector3(0.1f, 0.1f, 0.1f));
            fixedCrate.Position = new Vector3(0f, 0f, 0f);
            fixedCrate.Mass = 1;

            crate = new Crate(new Vector3(0.1f, 0.1f, 0.1f));
            crate.Position = new Vector3(-0f, -1f, -0f);
            crate.Mass = 1;

            cg = new ContactGenerator();
            cg.AddBody(fixedCrate);
            //cg.AddBody(crate);

            cg.AddJoint(new PhysiXEngine.Joint(fixedCrate,crate,new Vector3(0,0,0),new Vector3(0.1f, 0.1f, 0.1f),0.15f));

            camera = new Camera(this, new Vector3(0, 0, 0.1f),
                Vector3.Zero, Vector3.Up);
            Components.Add(camera);
            g = new Gravity(new Vector3(0f, -10f, 0f));
            //g.AddBody(crate);
            //zfixedCrate.InverseMass = 0;
            //fixedCrate.InverseInertiaTensor = new Matrix();
            //crate.InverseInertiaTensor = new Matrix();
            base.Initialize();
        }
Esempio n. 4
0
 public bool IsOnScreen(Camera c)
 {
     Rectangle cameraRectangle = new Rectangle((int)c.origin.X, (int)c.origin.Y, 800, 800);
     if (this.GetRectangle().Intersects(cameraRectangle))
         return true;
     else
         return false;
 }
Esempio n. 5
0
        public void Update(Player player, GameTime theGameTime, ExplosionHandler explosions, ItemHandler ih, SoundHandler sounds, Camera c)
        {
            foreach (Tower t in towers)
                t.Update(player, theGameTime, explosions, sounds, c);

            foreach (FlashDoor f in doors)
                f.Update(theGameTime);

            foreach (ZombieDispenser z in zombies)
                z.Update(theGameTime, explosions, ih, c);
        }
Esempio n. 6
0
 public void Draw(Camera camera)
 {
     Matrix[] transforms = new Matrix[model.Bones.Count];
     model.CopyAbsoluteBoneTransformsTo(transforms);
     foreach (ModelMesh mesh in model.Meshes)
     {
         foreach (BasicEffect be in mesh.Effects)
         {
             be.EnableDefaultLighting();
             be.World = mesh.ParentBone.Transform * Matrix.CreateScale(plane.Normal);
             be.View = camera.view;
             be.Projection = camera.projection;
         }
         mesh.Draw();
     }
 }
Esempio n. 7
0
        public void Update(GameTime theGameTime, ExplosionHandler explosions, ItemHandler ih, Camera c)
        {
            if(random.Next(200) == (int)X / 64)
            {
                if (random.Next(2) == 0) newZombie = new Zombie(new Vector2(this.X + 8, this.Y + 48), new Vector2(-1, 1)); else newZombie = new Zombie(new Vector2(this.X + 8, this.Y + 48), new Vector2(1, 1));
                newZombie.LoadContent(contentManager);
                zombies.Add(newZombie);
                newZombie = null;
            }

            foreach (Zombie z in zombies)
                if (z.Visible)
                    z.Update(theGameTime, c);

            this.RemoveZombies(explosions, ih);
            this.Animate();
        }
Esempio n. 8
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        protected override void Initialize()
        {
            b1 = new Ball(10f);
            b1.Texture = Content.Load<Texture2D>(@"basic_material");
            b1.Position = new Vector3(100,0,0);
            b1.model = Content.Load<Model>(@"ball");

            p1 = new Border(new Plane(new Vector3(50, 50, 50), 10));
            p1.model = Content.Load<Model>(@"plane");

            cg = new ContactGenerator();
            cg.AddBody(b1);
            cg.AddPlane(p1);

            camera = new Camera(this, new Vector3(0, 0, 100),
                Vector3.Zero, Vector3.Up);
            Components.Add(camera);
            base.Initialize();
        }
Esempio n. 9
0
 public void Draw(Camera camera)
 {
     Matrix[] transforms = new Matrix[model.Bones.Count];
     model.CopyAbsoluteBoneTransformsTo(transforms);
     foreach (ModelMesh mesh in model.Meshes)
     {
         foreach (BasicEffect be in mesh.Effects)
         {
             if (Texture != null)
             {
                 be.Texture = this.Texture;
                 be.TextureEnabled = true;
             }
             be.EnableDefaultLighting();
             be.World = mesh.ParentBone.Transform * Matrix.CreateScale(radius) * TransformMatrix;
             be.View = camera.view;
             be.Projection = camera.projection;
         }
         mesh.Draw();
     }
 }
Esempio n. 10
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        protected override void Initialize()
        {
            fixedCrate = new Crate(new Vector3(0.5f, 0.5f, 0.5f));
            fixedCrate.Position = new Vector3(0, 0, 0);
            fixedCrate.AddScaledOrientation(new Vector3(0,0,20));

            crate = new Crate(new Vector3(0.5f, 0.5f, 0.5f));
            crate.Position = new Vector3(0, 4, 0);
            crate.Mass = 10;

            cg = new ContactGenerator();
            cg.AddBody(fixedCrate);
            cg.AddBody(crate);

            camera = new Camera(this, new Vector3(0, 0, 0.1f),
                Vector3.Zero, Vector3.Up);
            Components.Add(camera);
            g = new Gravity(new Vector3(0f, -10f, 0f));

            //fixedCrate.InverseMass = 0;
            //fixedCrate.InverseInertiaTensor = new Matrix();

            base.Initialize();
        }
Esempio n. 11
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        protected override void Initialize()
        {
            fixedBall = new Ball(1);
            fixedBall.model = Content.Load<Model>(@"ball");

            fixedBall.Texture = Content.Load<Texture2D>(@"basic_material");
            fixedBall.Position = new Vector3(0, 4, 0);

            ball = new Ball(1);
            ball.Texture = Content.Load<Texture2D>(@"basic_material");
            ball.Position = new Vector3(0, 0, 0);
            ball.model = fixedBall.model;

            ball.Mass = 10;

            cg = new ContactGenerator();
            cg.AddBody(fixedBall);
            cg.AddBody(ball);
            cg.AddConductor(new Cable(fixedBall, ball, 10, 0.7f));

            //////////////////////////////////////////////////
            fixedBall2 = new Ball(1);
            fixedBall2.model = Content.Load<Model>(@"ball");

            fixedBall2.Texture = Content.Load<Texture2D>(@"basic_material");
            fixedBall2.Position = new Vector3(-5, 4, 0);

            ball2 = new Ball(1);
            ball2.Texture = Content.Load<Texture2D>(@"basic_material");
            ball2.Position = new Vector3(-5, 0, 0);
            ball2.model = fixedBall.model;

            ball2.Mass = 10;

            cg.AddBody(fixedBall2);
            cg.AddBody(ball2);
            cg.AddConductor(new Rod(fixedBall2, ball2, 3));

            camera = new Camera(this, new Vector3(0, 0, 0.1f),
                Vector3.Zero, Vector3.Up);
            Components.Add(camera);
            g = new Gravity(new Vector3(0f, -10f, 0f));

            fixedBall.InverseMass = 0;
            fixedBall.InverseInertiaTensor = new Matrix();

            fixedBall2.InverseMass = 0;
            fixedBall2.InverseInertiaTensor = new Matrix();

            base.Initialize();
        }
Esempio n. 12
0
        private void UpdateAttack(MouseState mouseState, Camera camera)
        {
            //direction of new bullet
            float x = mouseState.X - (this.X - camera.origin.X);
            float y = mouseState.Y - (this.Y - camera.origin.Y);

            Vector2 dir = new Vector2(x, y);
            dir.Normalize();

            //coordinates of new bullet position
            float dist = Fsqrt((30 * 30 * Scale * Scale) + (7 * 7 * Scale * Scale)); //distance from Vector2.origin to position where new bullet appears
            float xx;
            float yy;
            if (currentFacing == Facing.Right)
            {
                xx = gunPosition.X + FCos(Rotation) * dist;
                yy = gunPosition.Y + FSin(Rotation) * dist;
            }
            else
            {
                xx = gunPosition.X - FCos(Rotation) * dist;
                yy = gunPosition.Y - FSin(Rotation) * dist;
            }

            newBullet = new Bullet(new Vector2(xx, yy), dir, this.Rotation);
            newBullet.LoadContent(contentManager);
            bullets.Add(newBullet);
            newBullet = null;
            reloadTime = 0.2f;
        }
Esempio n. 13
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        protected override void Initialize()
        {
            //crates = new Crate[NUM_CRATES];

            Ball b = new Ball(2);
            b.Position = Vector3.Up * 1000;

            cg = new ContactGenerator();
            cg.AddBody(b);

            joints = new Joint[NUM_JOINTS];
            balls = new Ball[NUM_BALLS];
            fixedBalls = new Ball[4];
            ground = new Crate(new Vector3(10, 1, 10));

            #region oldcode
            /*
            //Arms
            crates[0] = new Crate(new Vector3(0.3f, 1f, 0.2f));
            crates[1] = new Crate(new Vector3(0.3f, 1f, 0.2f));
            crates[2] = new Crate(new Vector3(0.3f, 1f, 0.2f));
            crates[3] = new Crate(new Vector3(0.3f, 1f, 0.2f));

            crates[4] = new Crate(new Vector3(0.4f, 0.3f, 0.6f));

            crates[5] = new Crate(new Vector3(0.3f, 0.3f, 0.6f));
            crates[6] = new Crate(new Vector3(0.4f, 0.3f, 0.7f));
            crates[7] = new Crate(new Vector3(0.4f, 0.5f, 0.4f));

            //Legs
            crates[8] = new Crate(new Vector3(0.2f, 0.8f, 0.2f));
            crates[9] = new Crate(new Vector3(0.2f, 0.8f, 0.2f));
            crates[10] = new Crate(new Vector3(0.2f, 0.8f, 0.2f));
            crates[11] = new Crate(new Vector3(0.2f, 0.8f, 0.2f));

            crates[0].Position=new Vector3(0,0.9f,-0.5f);
            crates[1].Position = new Vector3(0, 3.159f, -0.56f);
            crates[2].Position = new Vector3(0, 0.993f, 0.5f);
            crates[3].Position = new Vector3(0, 3.15f, 0.56f);
            crates[4].Position = new Vector3(-0.054f, 4.683f, 0.013f);
            crates[5].Position = new Vector3(0.043f, 5.603f, 0.013f);
            crates[6].Position = new Vector3(0, 6.485f, 0.013f);
            crates[7].Position = new Vector3(0, 7.759f, 0.013f);
            crates[8].Position = new Vector3(0, 5.946f, -1.066f);
            crates[9].Position = new Vector3(0, 4.024f, -1.066f);
            crates[10].Position = new Vector3(0, 5.946f, 1.066f);
            crates[11].Position = new Vector3(0, 4.024f, 1.066f);

            for (int i = 0; i < NUM_CRATES; i++)
            {
                crates[i].Mass = 1;
                crates[i].Position = Vector3.Zero;
            }

            //right leg
            joints[0]=new Joint(crates[0],crates[1],new Vector3(0,1,0),new Vector3(0,-1,0),0.15f);

            //Left leg
            joints[1]=new Joint(crates[2],crates[3],new Vector3(0,1,0),new Vector3(0,-1,0),0.15f);

            //right arm
            joints[2]=new Joint(crates[9],crates[8],new Vector3(0,1,0),new Vector3(0,-1,0),0.15f);

            //left arm
            joints[3]=new Joint(crates[8],crates[1],new Vector3(0,1,0),new Vector3(0,-1,0),0.15f);

            //stomach to waist
            joints[4]=new Joint(crates[4],crates[5],new Vector3(0.05f,0.5f,0),new Vector3(-0.04f,-0.45f,0),0.15f);

            //
            joints[5]=new Joint(crates[5],crates[6],new Vector3(-0.04f,0.4f,0),new Vector3(0,-4,0),0.15f);

            joints[6]=new Joint(crates[6],crates[7],new Vector3(0,0.5f,0),new Vector3(0,-0.7f,0),0.15f);

            joints[7]=new Joint(crates[1],crates[4],new Vector3(0,1,0),new Vector3(0,-0.45f,-.5f),0.15f);

            joints[8]=new Joint(crates[3],crates[4],new Vector3(0,1,0),new Vector3(0,-0.45f,0.5f),0.15f);

            joints[9]=new Joint(crates[6],crates[8],new Vector3(0,0.3f,-.8f),new Vector3(0,0.8f,.3f),0.15f);

            joints[10]=new Joint(crates[6],crates[10],new Vector3(0,0.3f,0.8f),new Vector3(0,0.8f,-0.3f),0.15f);
            */
            #endregion

            #region
            ////Head
            //crates[0] = new Crate(new Vector3(0.1f / 2f, 0.1f / 2f, 0.1f / 2f));

            ////Arms
            //crates[1] = new Crate(new Vector3(0.1f / 2f, 0.2f / 2f, 0.1f / 2f));
            //crates[2] = new Crate(new Vector3(0.1f / 2f, 0.3f / 2f, 0.1f / 2f));
            //crates[3] = new Crate(new Vector3(0.1f / 2f, 0.2f / 2f, 0.1f / 2f));
            //crates[4] = new Crate(new Vector3(0.1f / 2f, 0.3f / 2f, 0.1f / 2f));

            ////Shoulder
            //crates[5] = new Crate(new Vector3(0.5f / 2f, 0.1f / 2f, 0.1f / 2f));

            ////chest
            //crates[6] = new Crate(new Vector3(0.4f / 2f, 0.1f / 2f, 0.1f / 2f));

            ////Stomach
            //crates[7] = new Crate(new Vector3(0.4f / 2f, 0.1f / 2f, 0.1f / 2f));

            ////Legs
            //crates[8] = new Crate(new Vector3(0.1f / 2f, 0.2f / 2f, 0.1f / 2f));
            //crates[9] = new Crate(new Vector3(0.1f / 2f, 0.2f / 2f, 0.1f / 2f));
            //crates[10] = new Crate(new Vector3(0.1f / 2f, 0.2f / 2f, 0.1f / 2f));
            //crates[11] = new Crate(new Vector3(0.1f / 2f, 0.2f / 2f, 0.1f / 2f));

            ////Head
            //crates[0].Position = new Vector3(0, 0.45f, 0);

            ////Arms
            //crates[1].Position = new Vector3(0.35f, 0.25f, 0);
            //crates[2].Position = new Vector3(0.35f, -.05f, 0);
            //crates[3].Position = new Vector3(-0.35f, .25f, 0);
            //crates[4].Position = new Vector3(-0.35f, -0.05f, 0);

            ////Shoulder
            //crates[5].Position = new Vector3(0, 0.3f, -.05f);

            ////chest
            //crates[6].Position = new Vector3(0, 0.15f, 0);

            ////Center Stomach
            //crates[7].Position = new Vector3(0, 0f, 0.05f);

            ////legs
            //crates[8].Position = new Vector3(0.15f, -0.2f, 0);
            //crates[9].Position = new Vector3(0.15f, -0.45f, 0);
            //crates[10].Position = new Vector3(-0.15f, -0.2f, 0);
            //crates[11].Position = new Vector3(-0.15f, -0.45f, 0);

            ////Head and shoulders :)
            //joints[0] = new Joint(crates[0], crates[5], new Vector3(0, -0.05f, -0.05f), new Vector3(0, 0.05f, 0), 0.05f);

            ////right arm
            //joints[1] = new Joint(crates[1], crates[2], new Vector3(0, -0.1f, 0.05f), new Vector3(0, 0.15f, 0), 0.05f);

            ////left arm
            //joints[2] = new Joint(crates[3], crates[4], new Vector3(0, -0.1f, 0.05f), new Vector3(0, 0.15f, 0), 0.05f);

            ////right leg
            //joints[3] = new Joint(crates[8], crates[9], new Vector3(0, -0.1f, 0.05f), new Vector3(0, 0.1f, 0), 0.05f);

            ////left leg
            //joints[4] = new Joint(crates[10], crates[11], new Vector3(0, -0.1f, 0.05f), new Vector3(0, 0.1f, 0), 0.05f);

            ////right arm with shoulders
            //joints[5] = new Joint(crates[5], crates[1], new Vector3(.25f, 0.05f, 0), new Vector3(-0.05f, 0.1f, 0), 0.05f);

            ////left arm with shoulders
            //joints[6] = new Joint(crates[5], crates[3], new Vector3(-.25f, 0.05f, 0), new Vector3(0.05f, 0.1f, 0), 0.05f);

            //joints[7] = new Joint(crates[5], crates[6], new Vector3(0, -0.05f, 0.05f), new Vector3(0, 0.05f, 0), 0.05f);

            //joints[8] = new Joint(crates[6], crates[7], new Vector3(0, -0.05f, 0), new Vector3(0, 0.05f, -.05f), 0.05f);

            //joints[9] = new Joint(crates[7], crates[8], new Vector3(.15f, -0.05f, 0), new Vector3(0, 0.1f, 0), 0.05f);

            //joints[10] = new Joint(crates[7], crates[10], new Vector3(-.15f, -0.05f, 0), new Vector3(0, 0.1f, 0), 0.05f);
            #endregion

            #region newBall
            balls[0] = new Ball(0.1f);
            balls[1] = new Ball(0.15f);
            balls[2] = new Ball(0.15f);
            balls[3] = new Ball(0.05f);
            balls[4] = new Ball(0.05f);
            balls[5] = new Ball(0.05f);
            balls[6] = new Ball(0.05f);
            balls[7] = new Ball(0.05f);
            balls[8] = new Ball(0.05f);
            balls[9] = new Ball(0.05f);
            balls[10] = new Ball(0.05f);
            balls[11] = new Ball(0.05f);
            balls[12] = new Ball(0.05f);
            balls[13] = new Ball(0.05f);
            balls[14] = new Ball(0.05f);
            fixedBalls[0] = new Ball(0.05f);
            fixedBalls[1] = new Ball(0.05f);
            fixedBalls[2] = new Ball(0.05f);
            fixedBalls[3] = new Ball(0.05f);
            #endregion

            #region position
            balls[0].Position = new Vector3(0, 0.6f, 0);
            balls[1].Position = new Vector3(0, 0.3f, 0);
            balls[2].Position = new Vector3(0, -0.05f, 0);

            balls[3].Position = new Vector3(0.25f, 0.3f, 0);
            balls[4].Position = new Vector3(0.25f, 0.15f, 0);
            balls[5].Position = new Vector3(0.25f, 0, 0);
            balls[6].Position = new Vector3(-0.25f, 0.3f, 0);
            balls[7].Position = new Vector3(-0.25f, 0.15f, 0);
            balls[8].Position = new Vector3(-0.25f, 0, 0);

            balls[9].Position = new Vector3(0.1f, -.25f, 0);
            balls[10].Position = new Vector3(0.1f, -.4f, 0);
            balls[11].Position = new Vector3(0.1f, -.55f, 0);
            balls[12].Position = new Vector3(-0.1f, -.25f, 0);
            balls[13].Position = new Vector3(-0.1f, -.4f, 0);
            balls[14].Position = new Vector3(-0.1f, -.55f, 0);

            fixedBalls[0].Position = new Vector3(0.7f, 0.6f, 0);
            fixedBalls[1].Position = new Vector3(-0.7f, 0.6f, 0);
            fixedBalls[2].Position = new Vector3(0.7f, -1, 0);
            fixedBalls[3].Position = new Vector3(-0.7f, -1, 0);

            ground.Position = new Vector3(0, -3, 0);
            #endregion
            #region Masses
            balls[0].Mass = 5;
            balls[1].Mass = 5;
            balls[2].Mass = 5;
            balls[3].Mass = 1;
            balls[4].Mass = 1;
            balls[5].Mass = 1;
            balls[6].Mass = 1;
            balls[7].Mass = 1;
            balls[8].Mass = 1;
            balls[9].Mass = 1;
            balls[10].Mass = 1;
            balls[11].Mass = 1;
            balls[12].Mass = 1;
            balls[13].Mass = 1;
            balls[14].Mass = 1;
            #endregion

            //head and shoulder :)
            joints[0] = new Joint(balls[0], balls[1], new Vector3(0, -0.1f,0f), new Vector3(0, 0.15f, 0), 0.05f);

            joints[1] = new Joint(balls[1], balls[2], new Vector3(0, -0.15f, 0), new Vector3(0, 0.15f, 0), 0.05f);

            //right arm with shoulders
            joints[2] = new Joint(balls[1], balls[3], new Vector3(0.1f, 0.1f, 0), new Vector3(-0.04f, 0.03f, 0), 0.05f);

            //left arm with shoulders
            joints[3] = new Joint(balls[1], balls[6], new Vector3(-0.1f, 0.1f, 0), new Vector3(0.04f, 0.03f, 0), 0.05f);

            //right arm
            joints[4] = new Joint(balls[3], balls[4], new Vector3(0, -0.05f, 0), new Vector3(0, 0.05f, 0), 0.05f);
            joints[5] = new Joint(balls[4], balls[5], new Vector3(0, -0.05f, 0), new Vector3(0, 0.05f, 0), 0.05f);

            //left arm
            joints[6] = new Joint(balls[6], balls[7], new Vector3(0, -0.05f, 0), new Vector3(0, 0.05f, 0), 0.05f);
            joints[7] = new Joint(balls[7], balls[8], new Vector3(0, -0.05f, 0), new Vector3(0, 0.05f, 0), 0.05f);

            //Stomach with right leg
            joints[8] = new Joint(balls[2], balls[9], new Vector3(0.1f, -0.15f, 0), new Vector3(0, 0.05f, 0), 0.05f);

            //Stomach with left leg
            joints[9] = new Joint(balls[2], balls[12], new Vector3(-.1f, -0.15f, 0), new Vector3(0, 0.05f, 0), 0.05f);

            //right leg
            joints[10] = new Joint(balls[9], balls[10], new Vector3(0, -0.05f, 0), new Vector3(0, 0.05f, 0), 0.05f);
            joints[11] = new Joint(balls[10], balls[11], new Vector3(0, -0.05f, 0), new Vector3(0, 0.05f, 0), 0.05f);

            joints[12] = new Joint(balls[12], balls[13], new Vector3(0, -0.05f, 0), new Vector3(0, 0.05f, 0), 0.05f);
            joints[13] = new Joint(balls[13], balls[14], new Vector3(0, -0.05f, 0), new Vector3(0, 0.05f, 0), 0.05f);

            Model model = this.Content.Load<Model>(@"ball");
            Texture2D texture = this.Content.Load<Texture2D>(@"basic_material");

            for (int i = 0; i < NUM_BALLS; i++)
            {
                balls[i].model = model;
                balls[i].Texture = texture;
                cg.AddBody(balls[i]);
                //balls[i].Mass = 1;
            }

            for (int i = 0; i < 4; i++)
            {
                fixedBalls[i].Lock();
                fixedBalls[i].model = model;
                fixedBalls[i].Texture = texture;
            }

            cg.AddConductor(new Cable(balls[5], fixedBalls[0], (balls[5].Position - fixedBalls[0].Position).Length(), 0.5f));
            cg.AddConductor(new Cable(balls[8], fixedBalls[1], (balls[8].Position - fixedBalls[1].Position).Length(), 0.5f));
            cg.AddConductor(new Cable(balls[11], fixedBalls[2], (balls[11].Position - fixedBalls[2].Position).Length(), 0.5f));
            cg.AddConductor(new Cable(balls[14], fixedBalls[3], (balls[14].Position - fixedBalls[3].Position).Length(), 0.5f));

            ground.Lock();

            for (int i = 0; i < NUM_JOINTS; i++)
                cg.AddJoint(joints[i]);
            cg.AddBody(ground);
                camera = new Camera(this, new Vector3(0, 0, 0.1f),
                    Vector3.Zero, Vector3.Up);
            Components.Add(camera);
            g = new Gravity(new Vector3(0f, -1f, 0f));

            base.Initialize();
        }
Esempio n. 14
0
 public void Update(Camera c, int val)
 {
     this.val = val;
     barSource = new Rectangle(0, 16, val, 10);
 }
Esempio n. 15
0
        protected override void Initialize()
        {
            p = new Player(new Vector2(0, 0));
            l = new Level();
            l.Initialize(currentLevel, currentLevelType);

            items = new ItemHandler(this.Content);
            items.Initialize(currentLevel);

            enemies = new EnemyHandler();
            enemies.Initiliaze(currentLevel);
            explosions = new ExplosionHandler();
            sounds = new SoundHandler();

            camera = new Camera(graphics.GraphicsDevice.Viewport);

            ch = new CollisionHandler();

            this.ChangeLevel = false;

            base.Initialize();
        }
Esempio n. 16
0
        public void Update(Player p, GameTime theGameTime, ExplosionHandler explosions, SoundHandler sounds, Camera c)
        {
            foreach (Rocket r in rockets)
                if (r.Visible)
                    r.Update(theGameTime, new Vector2((p.X + 21 * p.Scale) - r.X, (p.Y + 3 * p.Scale) - r.Y)); //(p.x+21); (p.y+3) so it doesn't aim at player.origin

            if (reloadTime < initRealoadTime)
                reloadTime += (float)theGameTime.ElapsedGameTime.TotalSeconds;

            //this.Animate();
            this.RemoveRocket(explosions, sounds, p);

            this.OnScreen = this.X - c.origin.X < 800 ? true : false;

            if (!OnScreen)
                return;

            float dx = this.Position.X - p.X;
            float dy = this.Position.Y - p.Y;
            float dist = dx * dx + dy * dy;     //distance from player to tower

            if (dx > 64 && dist < vision * vision && (dy < 100 && dy > -30)) //if distance.X < 64 and distance y < 100 && > 30 then Rotate - facing player
            {
                this.Rotation = FAtan((dy + 2) / dx); //(y+2) so it doesn't aim at very top of head
                lightColor = 2;
                this.SeePlayer = true;
            }
            else
            {
                lightColor = 0;
                this.SeePlayer = false;
            }

            if (reloadTime > initRealoadTime && SeePlayer)
            {
                rocketDirection = new Vector2((p.X + 21 * p.Scale) - this.X, (p.Y + 3 * p.Scale) - this.Y); //(p.Y + 3) so it doesn't shoot on top of head
                rocketDirection.Normalize();

                float xx = this.X + FCos(Rotation) * Fsqrt((32 * 32 * Scale * Scale) + (9 * 9 * Scale * Scale)); //x coordinate of new rocket

                newRocket = new Rocket(new Vector2(xx, Y + 5 * Scale), rocketDirection, this.Rotation);
                newRocket.LoadContent(contentManager);
                rockets.Add(newRocket);
                newRocket = null;
                reloadTime = 0f;
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        protected override void Initialize()
        {
            balls = new Ball[10];
            fixedBalls = new Ball[10];
            Model mod = Content.Load<Model>(@"ball");
            Texture2D tex = Content.Load<Texture2D>(@"basic_material");

            g = new Gravity(Vector3.Down );

            for (int i = 0; i < 10; i++)
            {
                balls[i] = new Ball(0.2f);
                fixedBalls[i] = new Ball(0.1f);

                balls[i].model = mod;
                fixedBalls[i].model = mod;

                balls[i].Mass = 2;
                fixedBalls[i].InverseMass = 0;
                fixedBalls[i].InverseInertiaTensor = new Matrix();
                balls[i].InverseInertiaTensor = new Matrix();
                g.AddBody(balls[i]);

                balls[i].Texture = tex;
                fixedBalls[i].Texture = tex;
            }

            balls[0].Position = new Vector3(0, 0, 0);
            balls[1].Position = new Vector3(1, 0, 0);
            balls[2].Position = new Vector3(2, 0, 0);
            balls[3].Position = new Vector3(3, 0, 0);
            balls[4].Position = new Vector3(4, 0, 0);
            balls[5].Position = new Vector3(0, 0, 3);
            balls[6].Position = new Vector3(1, 0, 3);
            balls[7].Position = new Vector3(2, 0, 3);
            balls[8].Position = new Vector3(3, 0, 3);
            balls[9].Position = new Vector3(4, 0, 3);

            fixedBalls[0].Position = new Vector3(0, 1.0f, 0);
            fixedBalls[1].Position = new Vector3(1, 1f, 0);
            fixedBalls[2].Position = new Vector3(2, 1f, 0);
            fixedBalls[3].Position = new Vector3(3, 1f, 0);
            fixedBalls[4].Position = new Vector3(4, 1f, 0);
            fixedBalls[5].Position = new Vector3(0, 1f, 3);
            fixedBalls[6].Position = new Vector3(1, 1f, 3);
            fixedBalls[7].Position = new Vector3(2, 1f, 3);
            fixedBalls[8].Position = new Vector3(3, 1f, 3);
            fixedBalls[9].Position = new Vector3(4, 1f, 3);

            cg = new ContactGenerator();

            for (int i = 0; i < 10; i++)
            {
                cg.AddBody(balls[i]);
                cg.AddBody(fixedBalls[i]);
                cg.AddConductor(new Cable(fixedBalls[i], balls[i], 2, 0.7f));

            }

            for (int i = 0; i < 5; i++)
            {
                cg.AddConductor(new Rod(balls[i], balls[i + 5], 3));

            }

            //cg.velocityIterations = 8;
            //cg.friction = 0;
            //cg.restitution = 0.5f;

            for (int i = 0; i < 4; i++)
            {
                cg.AddConductor(new Rod(balls[i], balls[i + 1], 1));
                cg.AddConductor(new Rod(balls[9 - i], balls[9 - i - 1], 1));
            }
                camera = new Camera(this, new Vector3(0, 0, 0.1f),Vector3.Zero, Vector3.Up);
            Components.Add(camera);

            base.Initialize();
        }
Esempio n. 18
0
        public void Update(MouseState mouseState, KeyboardState currentKeyboardState, KeyboardState oldKeyboardState, GameTime theGameTime, Camera camera, ExplosionHandler explosions)
        {
            hb.Update(camera, (int)((double)Hitpoints * 1.18));

            if ((mouseState.X + camera.origin.X) - this.X > 0)
                currentFacing = Facing.Right;
            else
                currentFacing = Facing.Left;

            //aiming
            float dx = (mouseState.X + camera.origin.X) - this.X;
            float dy = (mouseState.Y + camera.origin.Y) - this.Y;
            if (dx > 15 || dx < 15)
                this.Rotation = FAtan((dy / 10) / (dx / 10));

            //door switch interaction
            if (IntersectWithSwitch != null && IntersectWithSwitch.Switch && UseKeyPressed(currentKeyboardState, oldKeyboardState))
                IntersectWithSwitch.Switch = false;
            else if (IntersectWithSwitch != null && !IntersectWithSwitch.Switch && UseKeyPressed(currentKeyboardState, oldKeyboardState))
                IntersectWithSwitch.Switch = true;

            this.UpdateMovement(currentKeyboardState, oldKeyboardState, theGameTime);
            this.UpdateAnimation();

            if (mouseState.LeftButton == ButtonState.Pressed && reloadTime < 0.0f)
                this.UpdateAttack(mouseState, camera);

            foreach (Bullet b in bullets)
                if (b.Visible)
                    b.Update(theGameTime);

            this.RemoveBullets(explosions);

            if (reloadTime > 0.0f)
                reloadTime -= (float)theGameTime.ElapsedGameTime.TotalSeconds;

            if (this.Y > 500)
                this.Hitpoints = 0;

            if (currentFacing == Facing.Right)
                gunPosition = Crouching ? new Vector2(X + 27 * this.Scale, Y + 32 * this.Scale) : new Vector2(X + 26 * this.Scale, Y + 20 * this.Scale);
            else
                gunPosition = Crouching ? new Vector2(X + 36 * this.Scale, Y + 32 * this.Scale) : new Vector2(X + 38 * this.Scale, Y + 20 * this.Scale);

            crosshairPosition = new Vector2(mouseState.X - 4 + camera.origin.X, mouseState.Y - 4 + camera.origin.Y);
        }
Esempio n. 19
0
        public void HandleMovingCollision(Player p, Level l, Camera c)
        {
            p.Falling = true;

            playerRectangle = new Rectangle((int)(p.X + 24 * p.Scale), (int)(p.Y + 58 * p.Scale), (int)(16 * p.Scale), (int)(6 * p.Scale));
            foreach (MacroBlock mb in l.levelBlocks)
                if (mb.IsOnScreen(c))
                {
                    if (playerRectangle.Intersects(mb.GetRectangle()))
                    {
                        p.Falling = false;
                        break;
                    }
                }
        }
Esempio n. 20
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        protected override void Initialize()
        {
            crates = new Crate[NUM_CRATES];

            Ball b = new Ball(2);
            b.Position = Vector3.Up * 1000;

            cg = new ContactGenerator();
            cg.AddBody(b);

            joints = new Joint[NUM_JOINTS];

            #region oldcode
            /*
            //Arms
            crates[0] = new Crate(new Vector3(0.3f, 1f, 0.2f));
            crates[1] = new Crate(new Vector3(0.3f, 1f, 0.2f));
            crates[2] = new Crate(new Vector3(0.3f, 1f, 0.2f));
            crates[3] = new Crate(new Vector3(0.3f, 1f, 0.2f));

            crates[4] = new Crate(new Vector3(0.4f, 0.3f, 0.6f));

            crates[5] = new Crate(new Vector3(0.3f, 0.3f, 0.6f));
            crates[6] = new Crate(new Vector3(0.4f, 0.3f, 0.7f));
            crates[7] = new Crate(new Vector3(0.4f, 0.5f, 0.4f));

            //Legs
            crates[8] = new Crate(new Vector3(0.2f, 0.8f, 0.2f));
            crates[9] = new Crate(new Vector3(0.2f, 0.8f, 0.2f));
            crates[10] = new Crate(new Vector3(0.2f, 0.8f, 0.2f));
            crates[11] = new Crate(new Vector3(0.2f, 0.8f, 0.2f));

            crates[0].Position=new Vector3(0,0.9f,-0.5f);
            crates[1].Position = new Vector3(0, 3.159f, -0.56f);
            crates[2].Position = new Vector3(0, 0.993f, 0.5f);
            crates[3].Position = new Vector3(0, 3.15f, 0.56f);
            crates[4].Position = new Vector3(-0.054f, 4.683f, 0.013f);
            crates[5].Position = new Vector3(0.043f, 5.603f, 0.013f);
            crates[6].Position = new Vector3(0, 6.485f, 0.013f);
            crates[7].Position = new Vector3(0, 7.759f, 0.013f);
            crates[8].Position = new Vector3(0, 5.946f, -1.066f);
            crates[9].Position = new Vector3(0, 4.024f, -1.066f);
            crates[10].Position = new Vector3(0, 5.946f, 1.066f);
            crates[11].Position = new Vector3(0, 4.024f, 1.066f);

            for (int i = 0; i < NUM_CRATES; i++)
            {
                crates[i].Mass = 1;
                crates[i].Position = Vector3.Zero;
            }

            //right leg
            joints[0]=new Joint(crates[0],crates[1],new Vector3(0,1,0),new Vector3(0,-1,0),0.15f);

            //Left leg
            joints[1]=new Joint(crates[2],crates[3],new Vector3(0,1,0),new Vector3(0,-1,0),0.15f);

            //right arm
            joints[2]=new Joint(crates[9],crates[8],new Vector3(0,1,0),new Vector3(0,-1,0),0.15f);

            //left arm
            joints[3]=new Joint(crates[8],crates[1],new Vector3(0,1,0),new Vector3(0,-1,0),0.15f);

            //stomach to waist
            joints[4]=new Joint(crates[4],crates[5],new Vector3(0.05f,0.5f,0),new Vector3(-0.04f,-0.45f,0),0.15f);

            //
            joints[5]=new Joint(crates[5],crates[6],new Vector3(-0.04f,0.4f,0),new Vector3(0,-4,0),0.15f);

            joints[6]=new Joint(crates[6],crates[7],new Vector3(0,0.5f,0),new Vector3(0,-0.7f,0),0.15f);

            joints[7]=new Joint(crates[1],crates[4],new Vector3(0,1,0),new Vector3(0,-0.45f,-.5f),0.15f);

            joints[8]=new Joint(crates[3],crates[4],new Vector3(0,1,0),new Vector3(0,-0.45f,0.5f),0.15f);

            joints[9]=new Joint(crates[6],crates[8],new Vector3(0,0.3f,-.8f),new Vector3(0,0.8f,.3f),0.15f);

            joints[10]=new Joint(crates[6],crates[10],new Vector3(0,0.3f,0.8f),new Vector3(0,0.8f,-0.3f),0.15f);
            */
            #endregion

            //Head
            crates[0] = new Crate(new Vector3(0.1f / 2f, 0.1f / 2f, 0.1f / 2f));

            //Arms
            crates[1] = new Crate(new Vector3(0.1f / 2f, 0.2f / 2f, 0.1f / 2f));
            crates[2] = new Crate(new Vector3(0.1f / 2f, 0.3f / 2f, 0.1f / 2f));
            crates[3] = new Crate(new Vector3(0.1f / 2f, 0.2f / 2f, 0.1f / 2f));
            crates[4] = new Crate(new Vector3(0.1f / 2f, 0.3f / 2f, 0.1f / 2f));

            //Shoulder
            crates[5] = new Crate(new Vector3(0.5f / 2f, 0.1f / 2f, 0.1f / 2f));

            //chest
            crates[6] = new Crate(new Vector3(0.4f / 2f, 0.1f / 2f, 0.1f / 2f));

            //Stomach
            crates[7] = new Crate(new Vector3(0.4f / 2f, 0.1f / 2f, 0.1f / 2f));

            //Legs
            crates[8] = new Crate(new Vector3(0.1f / 2f, 0.2f / 2f, 0.1f / 2f));
            crates[9] = new Crate(new Vector3(0.1f / 2f, 0.2f / 2f, 0.1f / 2f));
            crates[10] = new Crate(new Vector3(0.1f / 2f, 0.2f / 2f, 0.1f / 2f));
            crates[11] = new Crate(new Vector3(0.1f / 2f, 0.2f / 2f, 0.1f / 2f));

            //Head
            crates[0].Position = new Vector3(0, 0.45f, 0);

            //Arms
            crates[1].Position = new Vector3(0.35f, 0.25f, 0);
            crates[2].Position = new Vector3(0.35f, -.05f, 0);
            crates[3].Position = new Vector3(-0.35f, .25f, 0);
            crates[4].Position = new Vector3(-0.35f, -0.05f, 0);

            //Shoulder
            crates[5].Position = new Vector3(0, 0.3f, -.05f);

            //chest
            crates[6].Position = new Vector3(0, 0.15f, 0);

            //Center Stomach
            crates[7].Position = new Vector3(0, 0f, 0.05f);

            //legs
            crates[8].Position = new Vector3(0.15f, -0.2f, 0);
            crates[9].Position = new Vector3(0.15f, -0.45f, 0);
            crates[10].Position = new Vector3(-0.15f, -0.2f, 0);
            crates[11].Position = new Vector3(-0.15f, -0.45f, 0);

            //Head and shoulders :)
            joints[0] = new Joint(crates[0], crates[5], new Vector3(0, -0.05f, -0.05f), new Vector3(0, 0.05f, 0), 0.05f);

            //right arm
            joints[1] = new Joint(crates[1], crates[2], new Vector3(0, -0.1f, 0.05f), new Vector3(0, 0.15f, 0), 0.05f);

            //left arm
            joints[2] = new Joint(crates[3], crates[4], new Vector3(0, -0.1f, 0.05f), new Vector3(0, 0.15f, 0), 0.05f);

            //right leg
            joints[3] = new Joint(crates[8], crates[9], new Vector3(0, -0.1f, 0.05f), new Vector3(0, 0.1f, 0), 0.05f);

            //left leg
            joints[4] = new Joint(crates[10], crates[11], new Vector3(0, -0.1f, 0.05f), new Vector3(0, 0.1f, 0), 0.05f);

            //right arm with shoulders
            joints[5] = new Joint(crates[5], crates[1], new Vector3(.25f, 0.05f, 0), new Vector3(-0.05f, 0.1f, 0), 0.05f);

            //left arm with shoulders
            joints[6] = new Joint(crates[5], crates[3], new Vector3(-.25f, 0.05f, 0), new Vector3(0.05f, 0.1f, 0), 0.05f);

            joints[7] = new Joint(crates[5], crates[6], new Vector3(0, -0.05f, 0.05f), new Vector3(0, 0.05f, 0), 0.05f);

            joints[8] = new Joint(crates[6], crates[7], new Vector3(0, -0.05f, 0), new Vector3(0, 0.05f, -.05f), 0.05f);

            joints[9] = new Joint(crates[7], crates[8], new Vector3(.15f, -0.05f, 0), new Vector3(0, 0.1f, 0), 0.05f);

            joints[10] = new Joint(crates[7], crates[10], new Vector3(-.15f, -0.05f, 0), new Vector3(0, 0.1f, 0), 0.05f);

            for (int i = 0; i < NUM_CRATES; i++)
            {
                crates[i].InverseMass = 1;
                //cg.AddBody(crates[i]);
                //crates[i].InverseInertiaTensor = new Matrix();
            }

            for (int i = 0; i < NUM_JOINTS; i++)
                cg.AddJoint(joints[i]);

            camera = new Camera(this, new Vector3(0, 0, 0.1f),
                Vector3.Zero, Vector3.Up);
            Components.Add(camera);
            g = new Gravity(new Vector3(0f, -1f, 0f));

            //crates[0].InverseMass = 0;
            //crates[7].InverseMass = 0;
            //crates[6].InverseInertiaTensor = new Matrix();

            base.Initialize();
        }
Esempio n. 21
0
        public void Update(GameTime theGameTime, Camera c)
        {
            if (realoadTime < initReloadTime)
                realoadTime += (float)theGameTime.ElapsedGameTime.TotalSeconds;

            this.CanBite = realoadTime >= initReloadTime ? true : false;

            this.OnScreen = this.X - c.origin.X < 820 ? true : false;

            if (Falling)
            {
                DY = 1f;
                velocity.Y += gravity;
            }
            else
                velocity.Y = 0;

            this.Position += direction * velocity * (float)theGameTime.ElapsedGameTime.TotalSeconds;

            if (!this.Falling)
                this.Animate();
            else
                this.Source = sources[0];

            if (this.Hitpoints <= 0)
                this.Visible = false;
        }
Esempio n. 22
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        protected override void Initialize()
        {
            balls = new Ball[numberOfballs];
            fixedBall = new Ball(0.5f);
            Model mod = Content.Load<Model>(@"ball");
            Texture2D tex = Content.Load<Texture2D>(@"basic_material");

            g = new Gravity(Vector3.Down * 1);
            fixedBall.InverseMass = 0;
            fixedBall.InverseInertiaTensor = new Matrix();

            fixedBall.model = mod;

            for (int i = 0; i < numberOfballs; i++)
            {
                balls[i] = new Ball(0.1f);

                balls[i].model = mod;

                balls[i].Mass = 10;

                balls[i].InverseInertiaTensor = new Matrix();

                balls[i].Texture = tex;
                fixedBall.Texture = tex;
            }

            balls[0].Position = new Vector3(-0.25f, -1, 0);
            balls[1].Position = new Vector3(0.50f, -1, 0);
            balls[2].Position = new Vector3(1.00f, -1, 0);
            balls[3].Position = new Vector3(1.50f, -1, 0);

            fixedBall.Position = new Vector3(0, 0f, 0);

            cg = new ContactGenerator();

            for (int i = 0; i < numberOfballs; i++)
            {
                cg.AddBody(balls[i]);
                //cg.AddBody(fixedBall);
                cg.AddConductor(new Rod(fixedBall, balls[i], 2));

            }

            //cg.velocityIterations = numberOfballs ;
            //cg.positionIterations = numberOfballs*10 ;
            //cg.friction = .1f;
            //cg.restitution = 0.7f;

            camera = new Camera(this, new Vector3(0, 0, 0.1f), Vector3.Zero, Vector3.Up);
            Components.Add(camera);
            base.Initialize();
        }
Esempio n. 23
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            camera = new Camera(this, new Vector3(0, 0, 100),
                Vector3.Zero, Vector3.Up);
            Components.Add(camera);
            ball = new Ball(100f);
            dummy = new Ball(100f);
            crate = new Crate(new Vector3(1,1,1));
            crate.Position = new Vector3(20,20,20);
            //dummy.InverseMass = 0;
            //dummy.InverseInertiaTensor = new Matrix3();
            //spring = new Spring(ball, dummy, dummy.Position, 0.3f, 20.0f);
            //spring.AddBody(ball);
            g = new Gravity(Vector3.Down * 10f);
            g.AddBody(ball);
            //TODO determine which is down for the world
            //BoundingSphereRenderer.InitializeGraphics(GraphicsDevice, 10^100);

            base.Initialize();
        }
Esempio n. 24
0
 public void Draw(Camera camera)
 {
     foreach (Ball b in Balls)
     {
         b.Draw(camera);
     }
 }
Esempio n. 25
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        protected override void Initialize()
        {
            fixedBall = new Ball(0.1f);
            fixedBall.model = Content.Load<Model>(@"ball");
            fixedBall.Texture = Content.Load<Texture2D>(@"basic_material");
            fixedBall.Position = new Vector3(0, 4, 0);

            fixedBall.InverseMass = 0;
            fixedBall.InverseInertiaTensor = new Matrix();

            ball = new Ball(0.1f);
            ball.model = Content.Load<Model>(@"ball");

            ball.Texture = Content.Load<Texture2D>(@"basic_material");
            ball.Position = new Vector3(0, -4, 0);

            ball.Mass = 1;
            ball.InverseInertiaTensor = new Matrix();

            cg = new ContactGenerator();

            g = new Gravity(new Vector3(0f, -5f, 0f));

            rope = new Rope(4, cg, this, g);
            rope.AddUpperBody(fixedBall);
            rope.AddBottomBody(ball);

            cg.AddBody(fixedBall);
            cg.AddBody(ball);

            camera = new Camera(this, new Vector3(0, 0, 0.1f),
                Vector3.Zero, Vector3.Up);
            Components.Add(camera);

            base.Initialize();
        }