コード例 #1
0
        public string[] PrintGame(TetrisBoard tetrisBoard, TetrisBoard nextTetrimino, GameStats gameStats)
        {
            string[] boardRows         = PrintBoard(tetrisBoard);
            string[] nextTetriminoRows = PrintBoard(nextTetrimino);

            int totalWidth = 14 + 3;
            int innerWidth = 12 + 3;

            string scoreTitle  = PadOutString(" SCORE", innerWidth);
            string scoreAmount = PadOutString($" {gameStats.Score}", innerWidth);

            string lines  = PadOutString($" Lines: {gameStats.Lines}", innerWidth);
            string blocks = PadOutString($" Blocks: {gameStats.Shapes}", innerWidth);
            string level  = PadOutString($" Level: {gameStats.Level}", innerWidth);

            string blankLine14 = PadOutString(totalWidth);

            string[] gameFieldPrint =
            {
                $"┌{PrintLine(innerWidth)}┐ " + $" ┌{PrintLine(30)}┐",
                $"│{nextTetriminoRows[0]}│ " + $" │{boardRows[0]}│",
                $"│{nextTetriminoRows[1]}│ " + $" │{boardRows[1]}│",
                $"│{nextTetriminoRows[2]}│ " + $" │{boardRows[2]}│",
                $"│{nextTetriminoRows[3]}│ " + $" │{boardRows[3]}│",
                $"└{PrintLine(innerWidth)}┘ " + $" │{boardRows[4]}│",
                $"{blankLine14} " + $" │{boardRows[5]}│",
                $"┌{PrintLine(innerWidth)}┐ " + $" │{boardRows[6]}│",
                $"│{scoreTitle}│ " + $" │{boardRows[7]}│",
                $"│{scoreAmount}│ " + $" │{boardRows[8]}│",
                $"└{PrintLine(innerWidth)}┘ " + $" │{boardRows[9]}│",
                $"{blankLine14} " + $" │{boardRows[10]}│",
                $"┌{PrintLine(innerWidth)}┐ " + $" │{boardRows[11]}│",
                $"│{lines}│ " + $" │{boardRows[12]}│",
                $"│{blocks}│ " + $" │{boardRows[13]}│",
                $"│{level}│ " + $" │{boardRows[14]}│",
                $"└{PrintLine(innerWidth)}┘ " + $" │{boardRows[15]}│",
                $"{blankLine14} " + $" │{boardRows[16]}│",
                $"{blankLine14} " + $" │{boardRows[17]}│",
                $"{blankLine14} " + $" │{boardRows[18]}│",
                $"{blankLine14} " + $" │{boardRows[19]}│",
                $"{blankLine14} " + $" └{PrintLine(30)}┘"
            };

            return(gameFieldPrint);
        }
コード例 #2
0
ファイル: Game.cs プロジェクト: michaeladionglay/Portfolio
        //-----------------------------------------------------------------------------
        // Game::Draw()
        //		This function is called once per frame
        //	    Use this for draw graphics to the screen.
        //      Only do rendering here
        //-----------------------------------------------------------------------------
        public override void Draw()
        {
            // Draw sprite with texture
            //pRedBird.Render();

            if (gameover)
            {
                SOM.drawBackground();
                SOM.drawStrings(stats);
                active_piece.draw();
                future_piece.draw();
                printGrid();
                SOM.drawGameOver(stats);
                stats = new GameStats();
                return;
            }
            // Update background
            SOM.drawBackground();
            SOM.drawStrings(stats);


            if (!startgame)
            {
                SOM.drawStartTetris();
                SOM.drawHighScores(stats);
            }

            if (startgame)
            {
                active_piece.draw();
                future_piece.draw();
            }

            if (paused && startgame)
            {
                SOM.drawPaused();
                //soundEngine.getAE().SetAllSoundsPaused(true);
            }

            if (!paused && startgame)
            {
                if (!muted)
                {
                    SOM.drawMenu();
                }
                if (muted)
                {
                    SOM.drawMutedMenu();
                }

                //soundEngine.getAE().SetAllSoundsPaused(false);
            }
            printGrid();


            //test drawing all shapes
            //if statement to make sure this only happens once, for testing purposes. Remove later to do stuff every frame

            /*if (only_one_run == 0)
             *          {
             *                  t.draw(t.orientation);
             *                  line.draw(line.orientation);
             *                  l1.draw(l1.orientation);
             *                  l2.draw(l2.orientation);
             *                  z1.draw(z1.orientation);
             *                  z2.draw(z2.orientation);
             *                  s.draw(s.orientation);
             *
             *                  only_one_run++;
             *
             *
             *                  t.erase(t.orientation);
             *                  line.erase(line.orientation);
             *                  l1.erase(l1.orientation);
             *                  l2.erase(l2.orientation);
             *                  z1.erase(z1.orientation);
             *                  z2.erase(z2.orientation);
             *                  s.erase(s.orientation);
             *
             *          }*/


            //test drawing a turned T, if staement is so that it only does it once

            /*if (turned.orientation == Shape.Orientation.ORIENT_0)
             *          {
             *                  turned.turn();
             *          }
             *          turned.draw(turned.orientation);
             *
             */

            /*
             *
             * // Draw one box, demo at position 1,1
             * SOM.drawBox(1, 1, DrawColor.Shade.COLOR_LT_GREEN);
             *
             * // Test play field
             * SOM.drawBox(Constants.GAME_MIN_X, Constants.GAME_MIN_Y, DrawColor.Shade.COLOR_ORANGE);
             * SOM.drawBox(Constants.GAME_MAX_X, Constants.GAME_MIN_Y, DrawColor.Shade.COLOR_YELLOW);
             * SOM.drawBox(Constants.GAME_MIN_X, Constants.GAME_MAX_Y, DrawColor.Shade.COLOR_RED);
             * SOM.drawBox(Constants.GAME_MAX_X, Constants.GAME_MAX_Y, DrawColor.Shade.COLOR_BLUE);
             */
        }