Пример #1
0
        public Form1()
        {
            InitializeComponent();
            menuStrip1.Renderer    = new ToolStripProfessionalRenderer(new MenuColorTable());
            menuStrip1.ForeColor   = Color.White;
            GameRenderer.Panel     = panel1;
            Game.ScoreLabel        = scoreLabel;
            Game.LivesLabel        = livesLabel;
            Game.DialogPanel       = DialogPanel;
            Instance               = this;
            toolStripTextBox1.Text = "Player";
            Timer          = new Timer();
            Timer.Interval = Game.UpdateTime;
            Timer.Tick    += delegate
            {
                Timer.Stop();
                Game.Refresh();
                Timer.Interval = Game.UpdateTime;
                if (TimerEnabled)
                {
                    Timer.Start();
                }
            };

            /*SpeedTimer = new Timer();
             * SpeedTimer.Interval = 10000;
             * SpeedTimer.Tick += delegate
             * {
             *  if (Game.UpdateTime - 100 > 0)
             *      Game.UpdateTime -= 100;
             *  Game.Length++;
             *  if (!TimerEnabled)
             *      SpeedTimer.Stop();
             * };*/
        }
Пример #2
0
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Down)
     {
         Game.MoveDirection = Direction.Down;
     }
     else if (e.KeyCode == Keys.Up)
     {
         Game.MoveDirection = Direction.Up;
     }
     else if (e.KeyCode == Keys.Left)
     {
         Game.MoveDirection = Direction.Left;
     }
     else if (e.KeyCode == Keys.Right)
     {
         Game.MoveDirection = Direction.Right;
     }
     else if (e.KeyCode == Keys.Enter)
     {
         if (MSGBox.OnCloseEvent != null)
         {
             MSGBox.OnCloseEvent(sender, e);
         }
     }
     else if (e.KeyCode == Keys.P || e.KeyCode == Keys.Pause)
     {
         Game.Paused = !Game.Paused;
     }
     else
     {
         return;
     }
     if (!Game.Paused)
     {
         Game.Refresh();
     }
 }