public GameTank(TankGame game, Image img, Size size, Point position, int speed = 0, bool isExist = true) : base(img, size, position, isExist) { _game = game; _speed = speed; this.Range = game.Range; }
/// <summary> /// 初始化游戏 /// </summary> private void InitialGame() { game = new TankGame(fps, DrawPanel, this, new Point(DrawPanel.Width, DrawPanel.Height)); game.RegisterActions("a", () => game.Tank.MoveLeft()); game.RegisterActions("d", () => game.Tank.MoveRight()); game.RegisterActions("w", () => game.Tank.MoveUp()); game.RegisterActions("s", () => game.Tank.MoveDown()); game.RegisterActions("left", () => game.Tank.MoveLeft()); game.RegisterActions("right", () => game.Tank.MoveRight()); game.RegisterActions("up", () => game.Tank.MoveUp()); game.RegisterActions("down", () => game.Tank.MoveDown()); game.RegisterActions("space", () => game.Tank.Fire()); game.RegisterActions("numpad0", () => game.Tank.Fire()); this.KeyDown += (object sender, KeyEventArgs e) => { if (e.KeyCode == Keys.P) { game.Pause(); } }; }
public Tank(TankGame game) : base(game, Resources.player, new Size(30, 30), new Point(100, 100), 5) { bullet = new Bullet(this.Game); }
public Bullet(TankGame game) : base(game, Resources.bullet, new Size(4, 4), new Point(100, 100), 15, false) { cooldown_Timer.AutoReset = false; cooldown_Timer.Elapsed += Cooldown_Timer_Elapsed; }