예제 #1
0
 /// <summary>
 /// Creates a new Falling Block with base block, field and position
 /// </summary>
 /// <param name="game">Game to bind to</param>
 /// <param name="block">Base block</param>
 /// <param name="field">Field container</param>
 /// <param name="x">X Grid position</param>
 /// <param name="y">Y Grid position</param>
 public FallingBlock(Game game, Block block, Field field, Int32 x, Int32 y)
     : this(game, block, field)
 {
     this.X = x;
     this.Y = y;
 }
예제 #2
0
 /// <summary>
 /// Creates a new Falling Block with base block and field
 /// </summary>
 /// <param name="game">Game to bind to</param>
 /// <param name="block">Base block</param>
 /// <param name="field">Field container</param>
 public FallingBlock(Game game, Block block, Field field)
     : this(game, block)
 {
     this.Field = field;
 }
예제 #3
0
        /// <summary>
        /// Initializes spriteset
        /// </summary>
        public override void Initialize()
        {
            _spritesLeft = new List<Sprite>();
            _spritesRight = new List<Sprite>();

            var block = new Block(this.Type);
            _field = new DummyField(this.Game, block.Width + 4, block.Height + 4 + SpriteField.HiddenRows);

            // Add for each rotation left
            for (Int32 i = 0; i < 4; i++)
            {
                // Get kick values and make sprites
                _spritesLeft.AddRange(GetMovementSprites(block, WallkickData.LeftMovements[new Tuple<int, int>(block.Width, block.Rotation)], block.Rotation + 1, i));
                block.Rotation--;
            }

            // Add for each rotation right
            for (Int32 i = 0; i < 4; i++)
            {
                // Get kick values and make sprites
                _spritesRight.AddRange(GetMovementSprites(block, WallkickData.RightMovements[new Tuple<int, int>(block.Width, block.Rotation)], block.Rotation - 1, i));
                block.Rotation++;
            }

            foreach (var sprite in _spritesLeft)
                sprite.Initialize();
            foreach (var sprite in _spritesRight)
                sprite.Initialize();
        }
예제 #4
0
 /// <summary>
 /// Creates a new Falling Block with base block
 /// </summary>
 /// <param name="game">Game to bind to</param>
 /// <param name="block">Base block</param>
 public FallingBlock(Game game, Block block)
     : this(game)
 {
     this.Block = block;
 }
예제 #5
0
파일: Field.cs 프로젝트: thexa4/time-tetris
 /// <summary>
 /// Checks if a block collides if placed on a position
 /// </summary>
 /// <param name="block">block to check</param>
 /// <param name="x">x position</param>
 /// <param name="y">y position</param>
 /// <returns>Collision flag</returns>
 public Boolean Collides(Block block, Int32 x, Int32 y)
 {
     for (Int32 a = 0; a < block.Width; a++)
         for (Int32 b = 0; b < block.Height; b++)
             if (block[a, block.Height - 1 - b] && this[x + a, y - b] != 0)
                 return true;
     return false;
 }