Ejemplo n.º 1
0
        public frmMain()
        {
            InitializeComponent();

            //Инициализация всех компонентов для рисования.
            //Фактически, полная загрузка приложения.
            btmp             = new Bitmap(pictureBox.Width, pictureBox.Height);
            g                = Graphics.FromImage(btmp);
            font             = new Font("Segoe print", 12);
            pictureBox.Image = btmp;

            wmp     = new WindowsMediaPlayer();
            pl      = new MySoundPlayer();
            wmp.URL = "Music\\menu.mp3";
            wmp.settings.setMode("Loop", true);
            wmp.settings.volume = 100;

            m_rnd = new Random();

            //ship = new Ship(pictureBox.Width, pictureBox.Height);
            space = new Space(pictureBox.Width, pictureBox.Height);
            Draw  = new MyDrawing(g, space.GetWidth, space.GetHeight);

            director = new StageDirector(pictureBox.Width, pictureBox.Height);

            x = space.GetWidth / 2;
            y = space.GetHeight - 100;

            pictureBox.Cursor.Dispose();
            Draw.Menu(pictureBox.Width, pictureBox.Height);

            now         = DateTime.Now;
            lastCurrent = now;
        }
Ejemplo n.º 2
0
 private void frmMain_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Space && !timerMain.Enabled)
     {
         director.Start(space, DateTime.Now);
         wmp.controls.stop();
         timerMain.Start();
         timerDrawing.Start();
         Cursor.Position = new Point(
             frmMain.ActiveForm.Location.X + space.GetShip.Xpoint,
             frmMain.ActiveForm.Location.Y + space.GetShip.Ypoint);
     }
     if (director.Playing)
     {
         if (e.KeyCode == Keys.P)
         {
             timerMain.Enabled    = !timerMain.Enabled;
             timerDrawing.Enabled = !timerDrawing.Enabled;
             if (timerMain.Enabled)
             {
                 director.MusicStart();
                 Cursor.Position = new Point(
                     frmMain.ActiveForm.Location.X + space.GetShip.Xpoint,
                     frmMain.ActiveForm.Location.Y + space.GetShip.Ypoint);
             }
             else
             {
                 director.MusicPause();
             }
         }
     }
     if (e.KeyCode == Keys.Escape)
     {
         director.MusicStop();
         director.Stop(space);
         timerMain.Enabled    = false;
         timerDrawing.Enabled = false;
         wmp.controls.play();
         Draw.Menu(pictureBox.Width, pictureBox.Height);
         pictureBox.Invalidate();
     }
     if (e.KeyCode == Keys.F1)
     {
         if (!director.Playing)
         {
             Draw.About(pictureBox.Width, pictureBox.Height);
             pictureBox.Invalidate();
         }
     }
 }