Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!startFlg)
            {
                startFlg = true;

                if (graSrc == null)
                {
                    graSrc = panel1.CreateGraphics();
                }

                timer1.Enabled = true;

                shape = ShapeFactory.CreateShape("LLeft", graSrc, shapeColor, backColor, framRec, squareSize);
                shape.heapArr = heapArr;
                shape.CreateShape();
            }
            else
            {
                if (pauseFlg)
                {
                    pauseFlg = false;
                    timer1.Enabled = true;
                }
                else
                {
                    pauseFlg = true;
                    timer1.Enabled = false;
                }
            }

            //shapePreview = ShapeFactory.CreateShape("LLeft", previewSrc, shapeColor, backColor, privewRec, squareSize);
            //shapePreview.shapeState = shape.shapeState;
            //shapePreview.CreateShape();

            //shape

            //graSrc.Dispose();
        }
Exemplo n.º 2
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Up)
            {
                shape.ChangeShapeState();
            }

            if (e.KeyCode == Keys.Down)
            {
                int downFlg = shape.MoveDown();

                if (downFlg == 1)
                {
                    heapArr = shape.heapArr;
                    shape = null;
                    shape = ShapeFactory.CreateShape("LLeft", graSrc, shapeColor, backColor, framRec, squareSize);
                    shape.CreateShape();
                    shape.heapArr = heapArr;

                }

                if (downFlg == -1)
                {
                    MessageBox.Show("GAME OVER");
                }

            }

            if (e.KeyCode == Keys.Left)
            {
                shape.MoveLeft();
            }
            if (e.KeyCode == Keys.Right)
            {
                shape.MoveRight();
            }
        }