Exemplo n.º 1
0
        private static void CreateBullets(Body ship)
        {
            Func<Vector2, Body> createBullet = pos =>
            {
                var body = new Body(world);
                body.BodyType = BodyType.Dynamic;
                body.IsBullet = true;

                var shape = new FarseerCircleShape(0.15f / 4, 1);
                body.CreateFixture(shape);

                body.Position = ship.Position + ship.GetWorldVector(pos);
                body.Rotation = ship.Rotation;
                body.ApplyForce(body.GetWorldVector(new Vector2(0.0f, -15f)));

                body.OnCollision += (a, b, contact) =>
                {
                    world.RemoveBody(body);
                    return false;
                };

                return body;
            };

            createBullet(new Vector2(-0.575f, -0.20f));
            createBullet(new Vector2(0.575f, -0.20f));
        }
Exemplo n.º 2
0
        private void CreateBullets()
        {
            Func<Vector2, Body> createBullet = pos =>
            {
                var body = new Body(Game.World);
                body.BodyType = BodyType.Dynamic;
                body.IsBullet = true;
                body.UserData = new RadarData(RadarType.Bullet, new NetBullet(body));

                var shape = new CircleShape(0.15f / 4, 1);
                body.CreateFixture(shape);

                body.Position = Body.Position + Body.GetWorldVector(pos);
                body.Rotation = Body.Rotation;
                body.ApplyForce(body.GetWorldVector(new Vector2(0.0f, -10f)));

                body.OnCollision += (a, b, contact) =>
                {
                    Game.World.RemoveBody(body);
                    return false;
                };

                return body;
            };

            createBullet(new Vector2(-0.575f, -0.20f));
            createBullet(new Vector2(0.575f, -0.20f));
        }