Exemplo n.º 1
0
        private async Task Repaint()
        {
            // Only allow the canvas to be drawn once if there is an invalidate, it's ok, the other canvas will soon be drawn
            if (_lastDrawn)
            {
                return;
            }

            _lastDrawn = true;
            await _screenCanvas.Draw(_container);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);
            GraphicsDevice.BlendState = BlendState.Opaque;

            // I'm setting this so that *both* sides of triangle are drawn
            // (so it won't be back-face culled if you move it, or the camera around behind it)
            GraphicsDevice.RasterizerState = RasterizerState.CullNone;

            var width  = this.Window.ClientBounds.Width;
            var height = this.Window.ClientBounds.Height;

            _screenCanvas.Clear();
            DrawHud(width, height);

            switch (_gameState)
            {
            case GameState.Title:
            {
                _currTitle.Draw(_screenCanvas, width, height);
                break;
            }

            case GameState.Game:
            {
                Level.Draw(_screenCanvas, width, height);
                break;
            }

            case GameState.Evolve:
            {
                Level.Draw(_screenCanvas, width, height);
                _screenCanvas.AddText($"GEN {_population.Generation}.{_population.ActiveIndex}", Justify.Right, 100, 200, 400, width, height);
                break;
            }
            }

            foreach (var pass in _basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                _screenCanvas.Draw(GraphicsDevice);
            }
            base.Draw(gameTime);
        }