private void AnaPencere_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Left: case Keys.A: if (zaman.Enabled) { ucksvr.X -= 15; } break; case Keys.Right: case Keys.D: if (zaman.Enabled) { ucksvr.X += 15; } break; case Keys.Space: if (zaman.Enabled) { Mermi mrm = new Mermi(ucksvr.X + 35, ucksvr.Y - 24, Width, Height); mermiler.Add(mrm); } break; case Keys.Enter: BackColor = System.Drawing.Color.Black; bitisMuzigi.Stop(); muzik.Play(); zamanSayac = 0; ucakDogmaSuresi = 140; zaman.Start(); bilgilendirmeYazisi.Visible = false; ucaklar = new List <Ucak>(); mermiler = new List <Mermi>(); ucksvr = new Ucaksavar(Width, Height); break; case Keys.Escape: MessageBox.Show("Çıkış yaptınız.", "Çıkış"); Close(); break; } Invalidate(); }//Key_Down sonu
public AnaPencere(int genislik, int yukseklik) { //PENCERE İLE İLGİLİ İŞLEMLER Width = genislik; Height = yukseklik; BackColor = System.Drawing.Color.Black; //MÜZİK İLE İLGİLİ İŞLEMLER muzik.SoundLocation = Application.StartupPath + "\\muzik.wav";; bitisMuzigi.SoundLocation = Application.StartupPath + "\\bitis.wav"; muzik.Play(); ucksvr = new Ucaksavar(Width, Height); //this.ClientSize.Height; Paint += AnaPencere_Paint; KeyDown += AnaPencere_KeyDown; YaziEkle(); zaman.Interval = 5; zaman.Tick += Zaman_Tick; zaman.Start(); DoubleBuffered = true; }