예제 #1
0
파일: Tetronimo.cs 프로젝트: ttocs7/tetris
 public Tetronimo(Tetronimo oldPiece)
 {
     _shape = new int[4, 4];
     shapeArray = allshapes[oldPiece._type];
     rotation = oldPiece.rotation;
     this._shape = shapeArray[rotation];
     location = oldPiece.location;
     _width = oldPiece.width;
     _height = oldPiece.height;
     GetDimensions();
 }
예제 #2
0
파일: Game1.cs 프로젝트: ttocs7/tetris
        //Maybe separate out Holding stuff to another function?
        public void DispatchPiece(bool holding = false)
        {
            if (state == gameState.COUNTDOWN)
                nextPiece = random.Next(0, 7);

            if (holding)
            {
                if (heldPiece > -1)
                {
                    int temp = currPiece.type;
                    currPiece = new Tetronimo(heldPiece);
                    heldPiece = temp;
                }
                else
                {
                    heldPiece = currPiece.type;
                    currPiece = new Tetronimo(nextPiece);
                    nextPiece = random.Next(0, 7);
                }
                //don't want them to spam the hold key, let another piece go first.
                justHeld = true;
            }
            else
            {
                currPiece = new Tetronimo(nextPiece);
                nextPiece = random.Next(0, 7);
                //reset justHeld, we got a new piece
                justHeld = false;
            }
            //if the piece can't be drawn, it's blocked, game ends.
            if (!ValidMove(direction.NEW_PIECE))
            {
                menu = new Menu(gameOverItems);
                state = gameState.GAME_OVER;
            }
            else
            {
                hardDropLocation = field.getHardDrop(currPiece.shape, currPiece.location);
            }
        }