Пример #1
0
        //use the following constructor when wanting to create collisdable groups of sprites
        public sprite(theGame reference, String contentAssetName, float width, float height, float X, float Y, CollisionCategory collCat,CollisionCategory collWith)
        {
            asset = reference.Content.Load<Texture2D>(contentAssetName);
            spriteOrigin = new Vector2(asset.Width / 2f, asset.Height / 2f);

            this.X = X;
            this.Y = Y;
            this.width = width;
            this.height = height;

            rectangle = new Rectangle((int)this.X, (int)this.Y, (int)width, (int)height);
            this.identity = identity;
            this.reference = reference;

            rectBody = BodyFactory.Instance.CreateRectangleBody(reference.ps, width, height, 1);//PHYSICS
            rectBody.Position = new FarseerGames.FarseerPhysics.Mathematics.Vector2(this.X, this.Y);//PHYSICS
            rectGeom = GeomFactory.Instance.CreateRectangleGeom(reference.ps, rectBody, this.width, this.height);//PHYSICS
            rectGeom.SetBody(rectBody);
            rectGeom.CollisionEnabled = true;
            this.rectGeom.CollisionResponseEnabled = true;
            this.rectGeom.CollisionCategories = collCat;
            this.rectGeom.CollidesWith = collWith;
            //this.rectGeom.CollisionCategories = CollisionCategory.
            rectBody.Enabled = true;//PHYSICS
            rectGeom.OnSeparation += OnSeperation;
            rectGeom.OnCollision += OnCollision;

            reference.ps.BroadPhaseCollider.OnBroadPhaseCollision += OnBroadPhaseCollision;
            reference.ps.Add(rectBody);
            reference.ps.Add(rectGeom);
        }
Пример #2
0
        public spriteRect(theGame reference, String contentAssetName, String identity, int width, int height, int X, int Y)
            : base(reference, contentAssetName, width, height, X, Y)
        {
            asset = reference.Content.Load<Texture2D>(contentAssetName);

            this.X = (int)(X);
            this.Y = (int)(Y);
            this.width = width;
            this.height = height;
            rectangle = new Rectangle((int)this.X, (int)this.Y, width, height);
            this.identity = identity;
            this.reference = reference;

            rectBody = BodyFactory.Instance.CreateRectangleBody(reference.ps, width, height, 1);//PHYSICS
            rectGeom = GeomFactory.Instance.CreateRectangleGeom(rectBody, this.width, this.height);//PHYSICS

            rectGeom.CollisionEnabled = true;
            this.rectGeom.CollisionResponseEnabled = true;
            //this.rectGeom.CollisionCategories = CollisionCategory.Cat1;
            //this.rectGeom.CollidesWith = CollisionCategory.All;
            this.rectGeom.CollidesWith = CollisionCategory.All;
            rectBody.Position = new FarseerGames.FarseerPhysics.Mathematics.Vector2(this.X, this.Y);//PHYSICS
            rectBody.Enabled = true;//PHYSICS
            reference.ps.Add(rectBody);
            reference.ps.Add(rectGeom);
        }
Пример #3
0
        public spriteCircle(theGame reference, String contentAssetName, String identity, int width, int height, int X, int Y)
            : base(reference, contentAssetName, width, height, X, Y)
        {
            asset        = reference.Content.Load <Texture2D>(contentAssetName);
            spriteOrigin = new Vector2(asset.Width / 2f, asset.Height / 2f);


            this.X      = X;
            this.Y      = Y;
            this.width  = width;
            this.height = height;


            rectangle      = new Rectangle((int)this.X, (int)this.Y, (int)width, (int)height);
            this.identity  = identity;
            this.reference = reference;

            rectBody          = BodyFactory.Instance.CreateEllipseBody(reference.ps, (width / 2f), (height / 2f), 1);            //PHYSICS
            rectBody.Position = new FarseerGames.FarseerPhysics.Mathematics.Vector2(this.X, this.Y);                             //PHYSICS
            rectGeom          = GeomFactory.Instance.CreateEllipseGeom(reference.ps, rectBody, (width / 2f), (height / 2f), 20); //PHYSICS
            rectGeom.SetBody(rectBody);
            rectGeom.CollisionEnabled = true;
            this.rectGeom.CollisionResponseEnabled = true;
            this.rectGeom.CollisionCategories      = CollisionCategory.All;
            this.rectGeom.CollidesWith             = CollisionCategory.All;

            rectBody.Enabled       = true;//PHYSICS
            rectGeom.OnSeparation += OnSeperation;
            rectGeom.OnCollision  += OnCollision;


            reference.ps.BroadPhaseCollider.OnBroadPhaseCollision += OnBroadPhaseCollision;
            reference.ps.Add(rectBody);
            reference.ps.Add(rectGeom);
        }
Пример #4
0
        //use the following constructor when you don't want to get a sprite
        //from the content pipeline

        //pics should be in the bin\debug folder
        public sprite(theGame reference, int width, int height, int X, int Y, String fileName, String identity)
        {
            asset          = Texture2D.FromFile(reference.graphics.GraphicsDevice, fileName, width, height); //aLoader.Load<Texture2D>("frog") as Texture2D;
            this.X         = (int)(X);
            this.Y         = (int)(Y);
            this.width     = width;
            this.height    = height;
            rectangle      = new Rectangle((int)this.X, (int)this.Y, width, height);
            this.identity  = identity;
            this.reference = reference;

            rectBody = BodyFactory.Instance.CreateRectangleBody(reference.ps, width, height, 1);    //PHYSICS
            rectGeom = GeomFactory.Instance.CreateRectangleGeom(rectBody, this.width, this.height); //PHYSICS

            rectGeom.CollisionEnabled = true;
            this.rectGeom.CollisionResponseEnabled = true;
            this.rectGeom.CollidesWith             = CollisionCategory.All;
            //this.rectGeom.CollisionCategories = CollisionCategory.Cat1;


            //this.rectGeom.CollidesWith = CollisionCategory.All;
            rectBody.Position      = new FarseerGames.FarseerPhysics.Mathematics.Vector2(this.X, this.Y); //PHYSICS
            rectBody.Enabled       = true;                                                                //PHYSICS
            rectGeom.OnSeparation += OnSeperation;
            rectGeom.OnCollision  += OnCollision;
            reference.ps.BroadPhaseCollider.OnBroadPhaseCollision += OnBroadPhaseCollision;
            reference.ps.Add(rectBody);
            reference.ps.Add(rectGeom);
        }
Пример #5
0
        public spriteRect(theGame reference, String contentAssetName, String identity, int width, int height, int X, int Y)
            : base(reference, contentAssetName, width, height, X, Y)
        {
            asset = reference.Content.Load <Texture2D>(contentAssetName);

            this.X         = (int)(X);
            this.Y         = (int)(Y);
            this.width     = width;
            this.height    = height;
            rectangle      = new Rectangle((int)this.X, (int)this.Y, width, height);
            this.identity  = identity;
            this.reference = reference;

            rectBody = BodyFactory.Instance.CreateRectangleBody(reference.ps, width, height, 1);    //PHYSICS
            rectGeom = GeomFactory.Instance.CreateRectangleGeom(rectBody, this.width, this.height); //PHYSICS

            rectGeom.CollisionEnabled = true;
            this.rectGeom.CollisionResponseEnabled = true;
            //this.rectGeom.CollisionCategories = CollisionCategory.Cat1;
            //this.rectGeom.CollidesWith = CollisionCategory.All;
            this.rectGeom.CollidesWith = CollisionCategory.All;
            rectBody.Position          = new FarseerGames.FarseerPhysics.Mathematics.Vector2(this.X, this.Y); //PHYSICS
            rectBody.Enabled           = true;                                                                //PHYSICS
            reference.ps.Add(rectBody);
            reference.ps.Add(rectGeom);
        }
Пример #6
0
 public sprite(theGame reference, int width, int height, int X, int Y, String fileName, String identity)
 {
     asset = Texture2D.FromFile(reference.graphics.GraphicsDevice, fileName, width, height); //aLoader.Load<Texture2D>("frog") as Texture2D;
     this.X = (int)(X);
     this.Y = (int)(Y);
     this.width = width;
     this.height = height;
     rectangle = new Rectangle((int)this.X, (int)this.Y, width, height);
     this.identity = identity;
     this.reference = reference;
 }
Пример #7
0
 public sprite(theGame reference, int width, int height, int X, int Y, String fileName, String identity)
 {
     asset          = Texture2D.FromFile(reference.graphics.GraphicsDevice, fileName, width, height); //aLoader.Load<Texture2D>("frog") as Texture2D;
     this.X         = (int)(X);
     this.Y         = (int)(Y);
     this.width     = width;
     this.height    = height;
     rectangle      = new Rectangle((int)this.X, (int)this.Y, width, height);
     this.identity  = identity;
     this.reference = reference;
 }
Пример #8
0
 // private Body _rectangleBody;
 //private Vector2 _origin;
 public sprite(theGame reference, String contentAssetName, String identity, int width, int height, int X, int Y)
 {
     asset = reference.Content.Load<Texture2D>(contentAssetName);
     //position = new Vector2(X, Y);
     this.X = (int)(X);
     this.Y = (int)(Y);
     this.width = width;
     this.height = height;
     rectangle = new Rectangle((int)this.X, (int)this.Y, width, height);
     this.identity = identity;
     this.reference = reference;
     //    _rectangleBody = BodyFactory.Instance.CreateRectangleBody(new PhysicsSimulator(new FarseerGames.FarseerPhysics.Mathematics.Vector2(0, 0)),width, height, 1);
      //   _rectangleBody.Position = new FarseerGames.FarseerPhysics.Mathematics.Vector2(this.X, this.Y);
     //    _origin = new Vector2(width / 2f, height / 2f);
 }
Пример #9
0
        // private Body _rectangleBody;
        //private Vector2 _origin;


        public sprite(theGame reference, String contentAssetName, String identity, int width, int height, int X, int Y)
        {
            asset = reference.Content.Load <Texture2D>(contentAssetName);
            //position = new Vector2(X, Y);
            this.X         = (int)(X);
            this.Y         = (int)(Y);
            this.width     = width;
            this.height    = height;
            rectangle      = new Rectangle((int)this.X, (int)this.Y, width, height);
            this.identity  = identity;
            this.reference = reference;
            //    _rectangleBody = BodyFactory.Instance.CreateRectangleBody(new PhysicsSimulator(new FarseerGames.FarseerPhysics.Mathematics.Vector2(0, 0)),width, height, 1);
            //   _rectangleBody.Position = new FarseerGames.FarseerPhysics.Mathematics.Vector2(this.X, this.Y);
            //    _origin = new Vector2(width / 2f, height / 2f);
        }
Пример #10
0
        public spritePolygon(theGame reference, String contentAssetName, String identity, int width, int height, int X, int Y)
            : base(reference, contentAssetName, width, height, X, Y)
        {
            //rectBody = BodyFactory.Instance.CreatePolygonBody(reference.ps, width/2f, 1);//PHYSICS
            //rectGeom = GeomFactory.Instance.CreatePolygonGeom ( (rectBody, width/2f,20);//PHYSICS

            rectGeom.CollisionEnabled = true;
            this.rectGeom.CollisionResponseEnabled = true;
            this.rectGeom.CollidesWith = CollisionCategory.All;
            //this.rectGeom.CollisionCategories = CollisionCategory.Cat1;

            //this.rectGeom.CollidesWith = CollisionCategory.All;
            rectBody.Position = new FarseerGames.FarseerPhysics.Mathematics.Vector2(this.X, this.Y);//PHYSICS
            rectBody.Enabled = true;//PHYSICS
            reference.ps.Add(rectBody);
            reference.ps.Add(rectGeom);
        }
Пример #11
0
        public spritePolygon(theGame reference, String contentAssetName, String identity, int width, int height, int X, int Y)
            : base(reference, contentAssetName, width, height, X, Y)
        {
            //rectBody = BodyFactory.Instance.CreatePolygonBody(reference.ps, width/2f, 1);//PHYSICS
            //rectGeom = GeomFactory.Instance.CreatePolygonGeom ( (rectBody, width/2f,20);//PHYSICS

            rectGeom.CollisionEnabled = true;
            this.rectGeom.CollisionResponseEnabled = true;
            this.rectGeom.CollidesWith             = CollisionCategory.All;
            //this.rectGeom.CollisionCategories = CollisionCategory.Cat1;


            //this.rectGeom.CollidesWith = CollisionCategory.All;
            rectBody.Position = new FarseerGames.FarseerPhysics.Mathematics.Vector2(this.X, this.Y); //PHYSICS
            rectBody.Enabled  = true;                                                                //PHYSICS
            reference.ps.Add(rectBody);
            reference.ps.Add(rectGeom);
        }
Пример #12
0
 public text(theGame game,String fontName,String data)
 {
     this.data = data;
     this.game = game;
     font = game.Content.Load<SpriteFont>(fontName);
 }
Пример #13
0
        //use the following constructor when you don't want to get a sprite
        //from the content pipeline
        //pics should be in the bin\debug folder
        public sprite(theGame reference,int width, int height, int X, int Y, String fileName, String identity)
        {
            asset = Texture2D.FromFile(reference.graphics.GraphicsDevice, fileName, width,height); //aLoader.Load<Texture2D>("frog") as Texture2D;
            this.X = (int)(X);
            this.Y = (int)(Y);
            this.width = width;
            this.height = height;
            rectangle = new Rectangle((int)this.X, (int)this.Y, width, height);
            this.identity = identity;
            this.reference = reference;

            rectBody = BodyFactory.Instance.CreateRectangleBody(reference.ps, width, height, 1);//PHYSICS
            rectGeom = GeomFactory.Instance.CreateRectangleGeom(rectBody, this.width, this.height);//PHYSICS

            rectGeom.CollisionEnabled = true;
            this.rectGeom.CollisionResponseEnabled = true;
            this.rectGeom.CollidesWith = CollisionCategory.All;
            //this.rectGeom.CollisionCategories = CollisionCategory.Cat1;

            //this.rectGeom.CollidesWith = CollisionCategory.All;
            rectBody.Position = new FarseerGames.FarseerPhysics.Mathematics.Vector2(this.X, this.Y);//PHYSICS
            rectBody.Enabled = true;//PHYSICS
            rectGeom.OnSeparation += OnSeperation;
            rectGeom.OnCollision += OnCollision;
            reference.ps.BroadPhaseCollider.OnBroadPhaseCollision += OnBroadPhaseCollision;
            reference.ps.Add(rectBody);
            reference.ps.Add(rectGeom);
        }
Пример #14
0
 public sound(theGame reference,String name)
 {
     this.reference =reference ;
     soundEffect = reference.Content.Load<SoundEffect>(name);
 }
Пример #15
0
 public text(theGame game, String spriteFont, String data)
 {
     this.data = data;
     this.game = game;
     font      = game.Content.Load <SpriteFont>(spriteFont);
 }
Пример #16
0
 public sound(theGame reference, String name)
 {
     this.reference = reference;
     soundEffect    = reference.Content.Load <SoundEffect>(name);
 }