示例#1
0
文件: View.cs 项目: RomanovaA/Squares
        //Конструктор
        public View(int fieldHeight, int fieldWidth, int squareHeight, Engine engine)
        {
            InitializeComponent();
            this.fieldHeight = fieldHeight;
            this.fieldWidth = fieldWidth;
            this.Height = FieldHeight * 100;
            this.Width = FieldWidth * 100;
            this.engine = engine;

            WIDTH = squareHeight;
        }
示例#2
0
        //Конструктор
        public GameForm()
        {
            InitializeComponent();

            //установка размера кубика, в зависимости от высоты экрана
            int tempX = (int)screenHeight / fieldHeight;
            if (tempX <= 100)
            {
                if (tempX % 2 == 0)
                    squareHeight = tempX - 20;
                else
                    squareHeight = tempX - 21;
            }
            else
                squareHeight = 100;

            //Установка размеров формы
            this.Width = fieldWidth * squareHeight + 100;
            this.Height = fieldHeight * squareHeight + 28 + 50;

            this.panel.Top = 0;
            this.panel.Left = fieldWidth * squareHeight;
            this.panel.Width = 100;
            this.panel.Height = fieldHeight * squareHeight + 28 + 50;

            this.pointsLbl.Top = fieldHeight * squareHeight;
            this.pointsLbl.Left = 0;
            this.pointsLbl.Width = fieldWidth * squareHeight;
            this.pointsLbl.Height = 50;
            this.pointsLbl.Text = "0";

            //создание и запуск Движка :)
            engine = new Engine(fieldWidth, fieldHeight, squareHeight);
            engine.gameStatus = GameStatus.pause;

            ticker = new System.Threading.Timer(IsEndGame, null, 1000, 1000);
            tickerScore = new System.Threading.Timer(ScoreChange, null, 50, 50);

            //добавление визуального компонента
            view = new View(fieldHeight, fieldWidth, squareHeight, engine);
            this.Controls.Add(view);

            engine.Score = 0;

            //MessageBox.Show(Convert.ToString(squareHeight), WINDOW, MessageBoxButtons.YesNo);
        }