コード例 #1
0
ファイル: ParallelGame.cs プロジェクト: stzbilj/Tetris
        public ParallelGame(List <TetrisObject> listOfShapes)
        {
            SuspendLayout();

            labelArray1 = new Label[20, 10];
            labelArray2 = new Label[20, 10];

            labelScore = new Label();
            labelLevel = new Label();
            labelFocus = new Label();

            labelArrayNext1 = new Label[3, 3];
            labelArrayNext2 = new Label[3, 3];

            InitializeComponent();
            game            = new GameScore(ref timer1);
            labelScore.Text = "SCORE:\n" + game.Score.ToString();
            labelLevel.Text = "LEVEL: " + game.Level.ToString();
            labelFocus.Text = "<--";

            this.CreateGrid();

            this.CreateHelp();
            tField1 = new TetrisField(ref labelArray1);
            tField2 = new TetrisField(ref labelArray2);


            this.BackColor = Color.CornflowerBlue;
            //game = new GameScore(ref timer1);

            listOfObjects = new TetrisObject[listOfShapes.Count];
            listOfObjects = listOfShapes.ToArray();
            newGame       = new Game(listOfShapes, false, false, true);

            mObject1 = new MovingObject(tField1, new TetrisObject(listOfObjects[GetRandomNumber()]), new TetrisObject(listOfObjects[GetRandomNumber()]), game);
            mObject2 = new MovingObject(tField2, new TetrisObject(listOfObjects[GetRandomNumber()]), new TetrisObject(listOfObjects[GetRandomNumber()]), game);

            this.ClientSize = new Size(10 * 32 + 3 * 32 + 50 + 10 * 32, 32 * 20 + 1);

            mObjectFocus = mObject1;
            flag         = true;


            ShowNextObject();
            ResumeLayout();
            this.KeyDown += MoveObject;

            game.Start();
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: stzbilj/Tetris
        public Form1(List <TetrisObject> listOfShapes, bool _addObstacles = false, bool _addGoldenPoints = false)
        {
            SuspendLayout();
            addObstacles    = _addObstacles;
            addGoldenPoints = _addGoldenPoints;
            blackFieldAdded = false;
            Random rnd = new Random();

            goldenPointsInterval = rnd.Next(15, 50);
            labelArray           = new Label[20, 10];
            labelScore           = new Label();
            labelLevel           = new Label();
            labelArrayNext       = new Label[3, 3];
            this.CreateGrid();
            this.CreateHelp();

            InitializeComponent();
            game            = new GameScore(ref timer1);
            labelScore.Text = "Score: " + game.Score.ToString();
            labelLevel.Text = "Level: " + game.Level.ToString();

            tField = new TetrisField(ref labelArray);

            this.BackColor = Color.CornflowerBlue;

            //game = new GameScore(ref timer1);

            listOfObjects = new TetrisObject[listOfShapes.Count];
            listOfObjects = listOfShapes.ToArray();
            newGame       = new Game(listOfShapes, _addObstacles, _addGoldenPoints);

            mObject         = new MovingObject(tField, new TetrisObject(listOfObjects[GetRandomNumber()]), new TetrisObject(listOfObjects[GetRandomNumber()]), game);
            this.ClientSize = new Size(10 * 32 + 3 * 32 + 50, 32 * 20 + 1);

            goldenPosition = new Tuple <int, int>(0, 0);

            ShowNextObject();
            ResumeLayout();
            this.KeyDown += MoveObject;

            game.Start();
        }
コード例 #3
0
 public MovingObject(TetrisField _tField, TetrisObject _tObject, TetrisObject _nextObject, GameScore _game)
 {
     tField       = _tField;
     tObject      = _tObject;
     nextObject   = _nextObject;
     game         = _game;
     row          = 0;
     column       = 4;
     goldenPoints = 0;
     InitialDraw();
 }
コード例 #4
0
ファイル: Form1.cs プロジェクト: stzbilj/Tetris
        public Form1(bool _addObstacles = false, bool _addGoldenPoints = false)
        {
            SuspendLayout();
            addObstacles         = _addObstacles;
            addGoldenPoints      = _addGoldenPoints;
            blackFieldAdded      = false;
            goldenPointsInterval = rnd.Next(15, 50);
            labelArray           = new Label[20, 10];
            labelScore           = new Label();
            labelLevel           = new Label();
            labelArrayNext       = new Label[3, 3];
            this.CreateGrid();
            this.CreateHelp();
            tField = new TetrisField(ref labelArray);

            this.BackColor = Color.CornflowerBlue;
            InitializeComponent();
            game = new GameScore(ref timer1);

            labelScore.Text = "SCORE:\n" + game.Score.ToString();
            labelLevel.Text = "LEVEL: " + game.Level.ToString();

            int[,] objekt1 = new int[, ] {
                { 1, 1, 1 }, { 0, 0, 0 }, { 0, 0, 0 }
            };
            TetrisObject tObject1 = new TetrisObject(objekt1);

            int[,] objekt2 = new int[, ] {
                { 0, 1, 0 }, { 0, 1, 0 }, { 1, 1, 0 }
            };
            TetrisObject tObject2 = new TetrisObject(objekt2);

            int[,] objekt3 = new int[, ] {
                { 0, 1, 0 }, { 0, 1, 0 }, { 0, 1, 1 }
            };
            TetrisObject tObject3 = new TetrisObject(objekt3);

            int[,] objekt4 = new int[, ] {
                { 1, 1, 0 }, { 1, 1, 0 }, { 0, 0, 0 }
            };
            TetrisObject tObject4 = new TetrisObject(objekt4);

            int[,] objekt5 = new int[, ] {
                { 1, 1, 0 }, { 0, 1, 1 }, { 0, 0, 0 }
            };
            TetrisObject tObject5 = new TetrisObject(objekt5);

            int[,] objekt6 = new int[, ] {
                { 0, 1, 0 }, { 1, 1, 1 }, { 0, 0, 0 }
            };
            TetrisObject tObject6 = new TetrisObject(objekt6);

            int[,] objekt7 = new int[, ] {
                { 0, 0, 0 }, { 0, 1, 1 }, { 1, 1, 0 }
            };
            TetrisObject tObject7 = new TetrisObject(objekt7);

            listOfObjects = new TetrisObject[7] {
                tObject1, tObject2, tObject3, tObject4, tObject5, tObject6, tObject7
            };
            List <TetrisObject> list = new List <TetrisObject>()
            {
                tObject1, tObject2, tObject3, tObject4, tObject5, tObject6, tObject7
            };

            newGame = new Game(list);

            mObject         = new MovingObject(tField, new TetrisObject(listOfObjects[GetRandomNumber()]), new TetrisObject(listOfObjects[GetRandomNumber()]), game);
            this.ClientSize = new Size(10 * 32 + 3 * 32 + 50, 32 * 20 + 1);

            goldenPosition = new Tuple <int, int>(0, 0);

            ShowNextObject();
            ResumeLayout();
            this.KeyDown += MoveObject;

            game.Start();
        }