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 Ball(float x, float y) : base(x, y) { img = Image.CreateRectangle((int)wh, (int)wh, Color.Blue); img.CenterOrigin(); AddGraphic(img); angle = Rand.Float(-135.0f, -45.0f); speed = new Vector2(5.0f, 5.0f); startPos = new Vector2(x, y); int collboxw = 4; cu = new BoxCollider((int)wh, collboxw, Tags.ball); cd = new BoxCollider((int)wh, collboxw, Tags.ball); cl = new BoxCollider(collboxw, (int)wh, Tags.ball); cr = new BoxCollider(collboxw, (int)wh, Tags.ball); cu.OriginX = wh / 2; cu.OriginY = wh / 2 + collboxw; cd.OriginX = wh / 2; cd.OriginY = -wh / 2; cl.OriginX = wh / 2 + collboxw; cl.OriginY = wh / 2; cr.OriginX = -wh / 2; cr.OriginY = wh / 2; AddCollider(cu); AddCollider(cd); AddCollider(cl); AddCollider(cr); Console.WriteLine(angle); }
public Block(float x, float y, int w, int h) : base(x, y) { img = Image.CreateRectangle(w, h, Color.Random); AddGraphic(img); collider = new BoxCollider(w, h, Tags.block); AddCollider(collider); }
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; }