Example #1
0
        /// <summary>
        /// Handles the player death.
        /// </summary>
        private async Task HandlePlayerDeathAsync()
        {
            var x = _playerShip.Col * 8 + 8;
            var y = 38 * 8;

            // Explosion
            await RunOutOfFrameAnimationAsync(
                () =>
            {
                for (var i = 0; i < 100; i++)
                {
                    Pen = this.GetRandomColour(includeBlack: false);
                    Line(x, y, _rnd.Next(ScreenCols * 8), _rnd.Next((ScreenRows - 2) * 8));
                    ForceFrame();
                }
            });

            _lives--;

            if (_lives == 0)
            {
                _state = GameState.GameOver;
            }

            _mothership.ClearBombs();

            Clear(Colors.Black);
        }