private void UpdateBlocks() { if (lastSeconds >= dropDelay) { // Do we need to drop some rows? if (RowsToDrop.Count != 0) { DropRows(); } else // move the current piece down { Block newBlock = new Block(CurrentBlock); newBlock.Translate(new Point(0, 1)); // lock block if (!newBlock.AboveGround() || !ValidPosition(newBlock)) { LockedNibbits.AddRange(CurrentBlock.EmancipateNibbits()); RemoveRows(); CurrentBlock = new Block(GraphicsDevice); } else CurrentBlock = newBlock; // Are any nibbits overflowing? foreach (Nibbit n in LockedNibbits) { if (n.CompareRow(0) < 1) State = GameState.Lose; } } lastSeconds = 0; } }
private void HandleMovement() { if (KeyPressed(Keys.Left)) { Block newBlock = new Block(CurrentBlock); newBlock.Translate(new Point(-1, 0)); if (ValidPosition(newBlock)) CurrentBlock = newBlock; } if (KeyPressed(Keys.Right)) { Block newBlock = new Block(CurrentBlock); newBlock.Translate(new Point(1, 0)); if (ValidPosition(newBlock)) CurrentBlock = newBlock; } if (KeyPressed(Keys.Up)) { Block newBlock = new Block(CurrentBlock); newBlock.Rotate(true); if (ValidPosition(newBlock)) CurrentBlock = newBlock; } if (Keyboard.GetState().IsKeyDown(Keys.Down)) dropDelay = 0.0625; else dropDelay = 0.5; }