AddBody() public méthode

Create a rigid body.
public AddBody ( Body body ) : void
body Body
Résultat void
Exemple #1
0
        public MasslessItem(Texture2D t, PhysicsShape shape, Vector2 position, World w)
            : base(position, w, t.Width, t.Height)
        {
            texture = t;
            body.BodyType = BodyType.Static;
            body.Position = position;

            switch (shape)
            {
                case PhysicsShape.Rectangle:
                    fixture = FixtureFactory.CreateRectangle(
                        texture.Width,
                        texture.Height,
                        0.0f,
                        Vector2.Zero,
                        body);
                    break;
            }

            //fixture.CollisionFilter.IgnoreCollisionWith();

            fixture.OnCollision += new OnCollisionEventHandler(this.OnCollision);
            w.AddBody(body);

            //drawOrigin = new Vector2(texture.Width / 2, texture.Height / 2);
            //drawRectangle = new Rectangle(0, 0, texture.Width, texture.Height);
        }
Exemple #2
0
        public Bomb(Vector2 position, World world, Vector2 velocity)
            : base(position, world, TextureStatic.Get("bomb").Width, TextureStatic.Get("bomb").Height)
        {
            body.BodyType = BodyType.Dynamic;
            texture = TextureStatic.Get("bomb");
            fixture = FixtureFactory.CreateCircle(TextureStatic.Get("bomb").Width / 2, 1, body);

            laidTime = GameClock.Now;
            world.AddBody(body);
            body.LinearVelocity = velocity;
        }
Exemple #3
0
 public Mauler(Vector2 position, World w)
     : base(position, w, TextureStatic.Get("solitudeMauler").Width, TextureStatic.Get("solitudeMauler").Height)
 {
     health = Settings.maulerHealth;
     world = w;
     body.BodyType = BodyType.Dynamic;
     body.Position = position;
     texture = TextureStatic.Get("solitudeMauler");
     fixture = FixtureFactory.CreateCircle(texture.Width/2, 0.25f, body, Vector2.Zero);
     fixture.OnCollision += new OnCollisionEventHandler(OnCollision);
     world.AddBody(body);
     targetPoint = body.Position;
 }
Exemple #4
0
 public Fighter(Vector2 position, World w)
     : base(position, w, TextureStatic.Get("fighter").Width, TextureStatic.Get("fighter").Height)
 {
     this.health = Settings.fighterHealth;
     world = w;
     lastShot = GameClock.Now;
     world = w;
     body.BodyType = BodyType.Dynamic;
     body.Position = position;
     texture = TextureStatic.Get("fighter");
     fixture = FixtureFactory.CreateRectangle(texture.Width, texture.Height, 0.25f, Vector2.Zero, body);
     world.AddBody(body);
     targetPoint = body.Position;
 }
Exemple #5
0
        public TyTaylor(World w, Vector2 position)
            : base(position, w, TextureStatic.Get("ty").Width, TextureStatic.Get("ty").Height)
        {
            health = Settings.TyHealth;
            world = w;
            lastShot = GameClock.Now;
            body.BodyType = BodyType.Dynamic;
            body.Position = position;
            texture = TextureStatic.Get("ty");
            fixture = FixtureFactory.CreateRectangle(texture.Width, texture.Height, 0.25f, Vector2.Zero, body);
            world.AddBody(body);
            targetPoint = body.Position;

            fixture.OnCollision += new OnCollisionEventHandler(this.OnCollision);
        }
Exemple #6
0
        public Body(World world, Object userData)
        {
            FixtureList = new List <Fixture>(32);

            World    = world;
            UserData = userData;

            FixedRotation   = false;
            IsBullet        = false;
            SleepingAllowed = true;
            Awake           = true;
            BodyType        = BodyType.Static;
            Enabled         = true;

            Xf.R.Set(0);

            world.AddBody(this);
        }
Exemple #7
0
        public Bullet(Vector2 velocity, Vector2 position, World w, Color color, Fixture sender)
            : base(position, w, 15f, 15f)
        {
            senderFixture = sender;
            world = w;
            BulletColor = color;
            body.BodyType = BodyType.Dynamic;
            body.IsBullet = true;
            body.LinearVelocity = velocity;
            body.Position = position;
            texture = TextureStatic.Get("bullet");
            fixture = FixtureFactory.CreateCircle(7f, 1, body);
            body.Mass = 0;
            fixture.Body.UserData = "bullet";
            body.Inertia = 0;
            body.Torque = 0;
            fixture.CollisionFilter.IgnoreCollisionWith(senderFixture);

            fixture.BeforeCollision += new BeforeCollisionEventHandler(BeforeCollision);
            fixture.OnCollision += new OnCollisionEventHandler(OnCollision);

            w.AddBody(body);
        }
Exemple #8
0
 public Sentinel(Vector2 position, Vector2 velocity, World w, int rate)
     : base(position, w, TextureStatic.Get("sentinel").Width, TextureStatic.Get("sentinel").Height)
 {
     health = Settings.sentinelHealth;
     patrolRate = rate;
     lastShot = GameClock.Now;
     lastTurn = lastShot;
     world = w;
     body.BodyType = BodyType.Dynamic;
     speed = velocity;
     body.LinearVelocity = velocity;
     //body.Position = position;
     texture = TextureStatic.Get("sentinel");
     fixture = FixtureFactory.CreateRectangle(texture.Width, texture.Height, 0.25f, Vector2.Zero, body);
     world.AddBody(body);
 }
Exemple #9
0
        public Body(World world, Object userData)
        {
            FixtureList = new List<Fixture>(32);

            World = world;
            UserData = userData;

            FixedRotation = false;
            IsBullet = false;
            SleepingAllowed = true;
            Awake = true;
            BodyType = BodyType.Static;
            Enabled = true;

            Xf.R.Set(0);

            world.AddBody(this);
        }
Exemple #10
0
        public Ship(SolitudeScreen s)
        {
            screen = s;
            toKill = new List<SolitudeObject>();

            roomStatus = new int[Settings.maxShipRows, Settings.maxShipColumns];

            random = new Random();
            //create the world, player, and boundaries
            PhysicalWorld = new World(Vector2.Zero);
            Player = new Player(new Vector2(900f, 830f), PhysicalWorld);

            border.Add(new Wall(new Vector2(192, 540), PhysicalWorld, 32, 1080, 1f, WallType.Smooth, Direction.Left));
            border.Add(new Wall(new Vector2(960, 108), PhysicalWorld, 1920, 64, 1f, WallType.Smooth, Direction.Left));
            border.Add(new Wall(new Vector2(1727, 540), PhysicalWorld, 32, 1080, 1f, WallType.Smooth, Direction.Left));
            border.Add(new Wall(new Vector2(960, 971), PhysicalWorld, 1920, 32, 1f, WallType.Smooth, Direction.Left));
            //term = new Terminal(new Vector2(500, 500), PhysicalWorld, "Derp Derp Derp Derp Derp Dfffffffferp Desdfrp Derp Derp Dffffferp Derp Derp Deffffffffffrp Derp Derp Deffrp Derp Derp Derp Derp");

            foreach (Wall j in border){
                PhysicalWorld.AddBody(j.body);
            }
            contents = new List<SolitudeObject>();
        }