using Microsoft.Xna.Framework; using Sprint3_actual.SpriteFactories; namespace Sprint3_actual.Blocks { class FallingBlock : IBlock { private ISprite sprite; private Rectangle posRectangle; private bool removed; private bool canMove; private const int blockWH = 48; private const int idleTime = 10; private int idleCount; private int topTile; public FallingBlock(int xPos, int yPos) { this.removed = false; this.posRectangle = new Rectangle(xPos, yPos, blockWH, blockWH); this.sprite = BlockSpriteFactory.Instance.CreateBlock(11, this); this.topTile = yPos; this.canMove = true; idleCount = 0; } public Rectangle getPos() { return posRectangle; } public void DrawBlock() { sprite.draw(); } public void UpdateBlock() { if(idleCount > idleTime) { this.posRectangle.Y += 4; } else { idleCount++; } if (this.posRectangle.Y == this.topTile + 4 * 48) { removed = true; } } public void Collide() { this.canMove = false; } public bool IsRemoved() { return removed; } public bool isMovable() { return this.canMove; } public bool isExit() { return false; } } }