Пример #1
0
    private Tetronimo SpawnTetronimo()
    {
        Tetronimo t = GenerateTetronimo();

        AddChild(t);
        currentTetronimo = t;
        t.Move(2, 2);
        gameBorder.Raise();

        return(t);
    }
Пример #2
0
    private void ControlCurrent(float delta)
    {
        currentFallDelay -= delta;
        timeHoldingPiece += delta;

        if (inputer.rotate)
        {
            currentTetronimo.Rotate();
        }
        if (inputer.fall)
        {
            currentFallDelay = 0f;
        }
        if (inputer.moveLeft)
        {
            currentTetronimo.Move(-1, 0);
            tetrominoDraw = true;
        }
        if (inputer.moveRight)
        {
            currentTetronimo.Move(1, 0);
            tetrominoDraw = true;
        }
        if (currentFallDelay <= 0f)
        {
            currentFallDelay = fallDelay;
            bool move = currentTetronimo.Move(0, 1);
            tetrominoDraw = true;
            if (!move)
            {
                MergeCurrentTetronimo();
                ScanLines();

                timeHoldingPiece = 0f;

                currentTetronimo.QueueFree();
                currentTetronimo = null;

                SpawnTetronimo();

                if (!currentTetronimo.Move(0, 0))
                {
                    OnGameOver();
                }

                draw          = true;
                tetrominoDraw = true;
            }
        }

        timeHoldingPiece += delta;
        if (timeHoldingPiece >= 10f)
        {
            currentTetronimo.QueueFree();
            currentTetronimo = null;

            SpawnTetronimo();

            tetrominoDraw = true;

            timeHoldingPiece = 0f;

            /*currentTetronimo.QueueFree();
             * currentTetronimo = null;
             * gameOver = true;
             * EmitSignal("GameOver");
             * Modulate *= new Color(.5f, .5f, .5f);*/
        }
    }