Rope Bridge Not Drawing

Nov 3, 2010 at 3:38 AM

Hey guys,

 

Im in need of some help.

Heres my Ropebridge.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using FarseerGames.FarseerPhysics;
using FarseerGames.FarseerPhysics.Dynamics;
using FarseerGames.FarseerPhysics.Factories;
using FarseerGames.FarseerPhysics.Collisions;


namespace Lucy_In_The_Sky_Episode_1
{
    public class Rope
    {

        public Texture2D texture;
        public Vector2 origin;
        public Path chain;
       public Vector2 startposition;
        public Vector2 endposition;
       // private LinearSpring _spring;

        public virtual Vector2 Startposition
        {
            get
            {
                return startposition;
            }
        }
        public virtual Vector2 Endposition
        {
            get
            {
                return  endposition;
            }
        }

        public Rope(PhysicsSimulator physics, Vector2 startposition, Vector2 endposition,float width,
            float height,float mass,bool start, bool end, Texture2D texture)
        {

            this.texture = texture;
            this.origin = new Vector2(texture.Width / 2, texture.Height / 2);
           // this.width = width;
            //this.height = height;

            SetupPhysics(physics, startposition, endposition, width, height,mass,start,end,texture);

        }

        protected virtual void SetupPhysics(PhysicsSimulator physics, Vector2 startposition, Vector2 endposition, float width,
            float height, float mass, bool start, bool end, Texture2D texture)
        {
            //texture = Game1.SprSinglePixel;
            //texture = CreateRectangleTexture(ScreenManager.GraphicsDevice, 20, 20, Color.White,
                                                                             //Color.Black);
            //origin = new Vector2(texture.Width / 2f, texture.Height / 2f);


            chain = ComplexFactory.Instance.CreateChain(Farseer.Physics, startposition, endposition, 20.0f, 10.0f, 1, true, true, LinkType.RevoluteJoint);
           
            chain.CreateGeoms(Farseer.Physics, 1);
        }

        public void Update(GameTime gT)
        {
            chain.Update();
        }
        /// <summary>
        /// Draws this physics object
        /// </summary>       
        /// <param name="spriteBatch">SpriteBatch used to draw this object, should've already started.</param>
        public virtual void Draw(GameTime gT, SpriteBatch SB)
        {
           
            foreach (Body body in chain.Bodies)
            {
                SB.Draw(texture, body.Position, null, Color.White, body.Rotation, origin, 1, SpriteEffects.None, 1);
            }
          

        }


    }
}

And here how i call for it in my level

 

public Level

{

 rope = new Rope(Farseer.Physics, new Vector2(150, 100), new Vector2(200, 300), 20.0f, 10.0f, 1, true, true, Game1.SprSinglePixel);

}

draw

{

rope.Draw(gT, SB);

}

 

Could you please help me and if you can see what im doing wrong

 

Thank You

JB