public void do_shot(string s, int index) // метод для стрельбы вражеского танка { switch (s) { case "Up": b = new Bullet(); b.Create(Object.Tnaks[index].Left, Object.Tnaks[index].Top - 5, 40, 40, f); b.Shoot("Up", 5); Object.Tnaks[index].BackgroundImage = Image.FromFile("Enemy_U.png"); break; case "Down": b = new Bullet(); b.Create(Object.Tnaks[index].Left, Object.Tnaks[index].Top + 5, 40, 40, f); b.Shoot("Down", 5); Object.Tnaks[index].BackgroundImage = Image.FromFile("Enemy_D.png"); break; case "Left": b = new Bullet(); b.Create(Object.Tnaks[index].Left - 5, Object.Tnaks[index].Top, 40, 40, f); b.Shoot("Left", 5); Object.Tnaks[index].BackgroundImage = Image.FromFile("Enemy_L.png"); break; case "Right": b = new Bullet(); b.Create(Object.Tnaks[index].Left + 5, Object.Tnaks[index].Top, 40, 40, f); b.Shoot("Right", 5); Object.Tnaks[index].BackgroundImage = Image.FromFile("Enemy_R.png"); break; } }
private void Form1_KeyDown(object sender, KeyEventArgs e) { try { switch (e.KeyCode.ToString()) { case "W": d.TankMove("W", 40, 0); Object.Tnaks[0].BackgroundImage = Image.FromFile("Frendly_U.png"); break; case "S": d.TankMove("D", 40, 0); Object.Tnaks[0].BackgroundImage = Image.FromFile("Frendly_D.png"); break; case "A": d.TankMove("L", 40, 0); Object.Tnaks[0].BackgroundImage = Image.FromFile("Frendly_L.png"); break; case "D": d.TankMove("R", 40, 0); Object.Tnaks[0].BackgroundImage = Image.FromFile("Frendly_R.png"); break; case "Up": b = new Bullet(); b.Create(Object.Tnaks[0].Left, Object.Tnaks[0].Top - 5, 40, 40, this); b.Shoot("Up", 5); Object.Tnaks[0].BackgroundImage = Image.FromFile("Frendly_U.png"); break; case "Down": b = new Bullet(); b.Create(Object.Tnaks[0].Left, Object.Tnaks[0].Top + 5, 40, 40, this); b.Shoot("Down", 5); Object.Tnaks[0].BackgroundImage = Image.FromFile("Frendly_D.png"); break; case "Left": b = new Bullet(); b.Create(Object.Tnaks[0].Left - 5, Object.Tnaks[0].Top, 40, 40, this); b.Shoot("Left", 5); Object.Tnaks[0].BackgroundImage = Image.FromFile("Frendly_L.png"); break; case "Right": b = new Bullet(); b.Create(Object.Tnaks[0].Left + 5, Object.Tnaks[0].Top, 40, 40, this); b.Shoot("Right", 5); Object.Tnaks[0].BackgroundImage = Image.FromFile("Frendly_R.png"); break; } } catch { } }