public Game() { InitializeComponent(); _player = new Player(); _player.DisplayOn(gameCanvas); _alien = new Alien(); _alien.DisplayOn(gameCanvas); _bombs = new BombCollection(); _lasers = new LaserCollection(); _animationTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(40) }; _animationTimer.Tick += animationTimer_Tick; _animationTimer.Start(); _bombTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) }; _bombTimer.Tick += bombTimer_Tick; _bombTimer.Start(); }
public void ShootLaser(LaserCollection lasers) { int laserX = X + Width / 2; int laserY = Y - Height; Laser laser = new Laser(laserX, laserY, lasers); laser.DisplayOn(canvas); }
public Laser(int x, int y, LaserCollection laserCollection) { _ellipse = new Ellipse { Fill = new SolidColorBrush(Colors.Black) }; _stepSize = 15; _laserCollection = laserCollection; X = x; Y = y; Width = 5; Height = 10; laserCollection.Add(this); }