public Explosion(Entity from, int radius) { this.SetPosition(from.X, from.Y); this.X = from.X + Global.GridSize / 2; this.Y = from.Y + Global.GridSize / 2; this.Radius = radius; this.LifeSpan = 60; int numberOfTiles = this.Radius * 2 - 1; int size = numberOfTiles * Global.GridSize; //vertical explosion var vertical = new BoxCollider(Global.GridSize, size, (int)CollisionTag.Explosion); vertical.CenterOrigin(); this.AddCollider(vertical); //horizontal explosion var horizontal = new BoxCollider(size, Global.GridSize, (int)CollisionTag.Explosion); horizontal.CenterOrigin(); this.AddCollider(horizontal); this._veritcalImage = Image.CreateRectangle(size, Global.GridSize, _color); this._veritcalImage.CenterOrigin(); this._horizontalImage = Image.CreateRectangle(Global.GridSize, size, _color); this._horizontalImage.CenterOrigin(); this.Graphics.AddRange(new[] { this._veritcalImage, this._horizontalImage }); this.Layer = 0; }
public int NumBounces = 0; // number of bounces/ricochets #endregion Fields #region Constructors public Bullet(Vector2 fired, float x = 0, float y = 0) { X = x; Y = y; if(fired == null) { fired = new Vector2(1, 0); } maxSpeed.X = 50; maxSpeed.Y = 50; mySpeed = fired; // Create sprite mySprite = Image.CreateRectangle(16, 16, Color.Yellow); mySprite.CenterOrigin(); mySprite.Angle = Util.Angle(mySpeed); AddGraphic(mySprite); // Create collider myCollider = new BoxCollider(16, 16, Tags.BULLET_COLLISION_PLAYER); myCollider.CenterOrigin(); AddCollider(myCollider); Layer = Layers.BULLET; LifeSpan = 600.0f; }
public Player(float x, float y) : base(x, y) { img = Image.CreateRectangle(width, height, Color.Gold); img.CenterOrigin(); AddGraphic(img); collider = new BoxCollider(width, height, Tags.player); collider.CenterOrigin(); AddCollider(collider); xL = x; }