文件名称:坦克游戏 Tank
文件大小:1.26MB
文件格式:RAR
更新时间:2016-01-29 04:12:24
小游戏
自编简易坦克游戏 using System; using System.Collections.Generic; using System.Text; using System.Drawing; using Tank.Properties; using System.Windows.Forms; namespace Tank { public class P1Tank:Player { private static Image[] imgTank1 = new Image[] { Resources.p1TankU , Resources.p1TankD , Resources.p1TankL, Resources.p1TankR }; public P1Tank(int x, int y, int speed, int life, directions dir) : base(x, y,life, speed,dir,imgTank1) { } public void KeyDown(KeyEventArgs e) { switch (e.KeyCode) { case Keys.W : dirU = true; break; case Keys.A: dirL = true; break; case Keys.D: dirR = true; break; case Keys.S: dirD = true; break; default: break; } if (e.KeyCode == Keys.W | e.KeyCode == Keys.A | e.KeyCode == Keys.S | e.KeyCode == Keys.D) isMove = true; AdjustDirection(); } public void Keyup(KeyEventArgs e) { switch (e.KeyCode) { case Keys.W: dirU = false; break; case Keys.A: dirL = false; break; case Keys.D: dirR = false; break; case Keys.S: dirD = false; break; case Keys.K: Fire(); break; default: break; } isMove = false; AdjustDirection(); } } }