Beispiel #1
0
        private void Update(object sender, EventArgs graph)
        {
            Drawings.Reset();
            if (!Drawings.Collide1())
            {
                Drawings.shape.Down();
            }
            else
            {
                Drawings.Share();
                Drawings.Cut(label1, label2);
                timer1.Interval = Drawings.interval;
                Drawings.shape.ResetBoxes(3, 0);
                if (Drawings.Collide1())
                {
                    Drawings.Clear();
                    timer1.Tick -= new EventHandler(Update);
                    timer1.Stop();
                    DialogResult result = MessageBox.Show($"Game Over \n Score: {Drawings.totScore} \n Do you want to play Again?"
                                                          , "Game Over", MessageBoxButtons.YesNo);
                    if (result == DialogResult.No)
                    {
                        Application.Exit();
                    }
                    Records.SaveForHighScores(name);

                    Initialize();
                }
            }
            Drawings.Share();
            Invalidate();
        }
Beispiel #2
0
        private void KeyboardKeys(object sender, KeyEventArgs graph)
        {
            switch (graph.KeyCode)
            {
            case Keys.Up:

                if (!Drawings.Intersection())
                {
                    Drawings.Reset();
                    Drawings.shape.Rotate();
                    Drawings.Share();
                    Invalidate();
                }
                break;

            case Keys.Space:
                timer1.Interval = 10;
                break;

            case Keys.Right:
                if (!Drawings.Collide2(1))
                {
                    Drawings.Reset();
                    Drawings.shape.Right();
                    Drawings.Share();
                    Invalidate();
                }
                break;

            case Keys.Left:
                if (!Drawings.Collide2(-1))
                {
                    Drawings.Reset();
                    Drawings.shape.Left();
                    Drawings.Share();
                    Invalidate();
                }
                break;
            }
        }