Microsoft.Xna.Framework.Graphics.SpriteBatch.End()

Here are the examples of the csharp api Microsoft.Xna.Framework.Graphics.SpriteBatch.End() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

173 Examples 7

19 Source : ConstructComponent.cs
with MIT License
from Big-BlueBerry

public override void Draw(SpriteBatch sb)
        {
            //_pos = Camera.Current.GetRay(Mouse.GetState().Position.ToVector2());
            sb.BeginAA();
            _pos = Mouse.GetState().Position.ToVector2() + Location;
            if (_wasDrawing || _drawState == DrawState.ELLIPSE_POINT)
            {
                if (_drawState == DrawState.CIRCLE)
                {
                    float radius = (_pos - _lastPoint.Coord).Length();
                    GUI.DrawCircle(sb, _lastPoint.Coord - Location, radius, 2, Color.DarkGray, 100);
                }
                else if (_drawState == DrawState.ELLIPSE)
                {
                    _lastPoint.Draw(sb);
                }
                else if (_drawState == DrawState.ELLIPSE_POINT)
                {
                    _ellipseLastPoint.Draw(sb);
                    Ellipse.FromThreeDots(_ellipseLastPoint, _lastPoint, Dot.FromCoord(_pos)).Draw(sb);
                }
                else if (_drawState == DrawState.SEGMENT)
                {
                    GUI.DrawLine(sb, _lastPoint.Coord - Location, _pos - Location, 2, Color.DarkGray);
                }
                else if (_drawState == DrawState.VECTOR)
                {
                    Vector.FromTwoDots(_lastPoint, Dot.FromCoord(_pos)).Draw(sb);
                }
                else if (_drawState == DrawState.LINE)
                {
                    Line.FromTwoPoints(_lastPoint.Coord, _pos).Draw(sb);
                }
                else if (_drawState == DrawState.DOT)
                {
                    _lastPoint.Draw(sb);
                }
            }

            UpdateLists(sb);
            sb.End();
        }

19 Source : AchievementsScreen.cs
with MIT License
from BrianPeek

public override void Draw(GameTime gameTime)
		{
			_spriteBatch.Begin();
				_spriteBatch.Draw(_background, Vector2.Zero, Color.White);
				if(_achievementData == null)
					FontManager.DrawShadowString(_spriteBatch, FontSize.Large, "Loading...", new Vector2(800, 320), Vector2.Zero, 1.0f, Color.White, Color.Black);
				else
				{
					foreach(AchievementDisplay ad in _achievementDisplay)
						ad.Draw(gameTime, _spriteBatch);
				}
			_spriteBatch.End();
		}

19 Source : RenderTargetScaler.cs
with MIT License
from BrianPeek

public void Draw()
		{
			if(!IsEnabled)
				return;

			PresentationParameters presentation = _graphicsDeviceManager.GraphicsDevice.PresentationParameters;

			float outputAspect = _game.Window.ClientBounds.Width / (float)_game.Window.ClientBounds.Height;
			float preferredAspect = _screenWidth / (float)_screenHeight;

			Rectangle dst;

			if (outputAspect <= preferredAspect)
			{
				// output is taller than it is wider, bars on top/bottom
				int presentHeight = (int)((_game.Window.ClientBounds.Width / preferredAspect) + 0.5f);
				int barHeight = (_game.Window.ClientBounds.Height - presentHeight) / 2;

				dst = new Rectangle(0, barHeight, _game.Window.ClientBounds.Width, presentHeight);
			}
			else
			{
				// output is wider than it is tall, bars left/right
				int presentWidth = (int)((_game.Window.ClientBounds.Height * preferredAspect) + 0.5f);
				int barWidth = (_game.Window.ClientBounds.Width - presentWidth) / 2;

				dst = new Rectangle(barWidth, 0, presentWidth, _game.Window.ClientBounds.Height);
			}

			_graphicsDeviceManager.GraphicsDevice.SetRenderTarget(null);

			// clear to get black bars
			_graphicsDeviceManager.GraphicsDevice.Clear(ClearOptions.Target, Color.Black, 1.0f, 0);

			// draw a quad to get the draw buffer to the back buffer
			_spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque);
				_spriteBatch.Draw(_drawBuffer, dst, Color.White);
			_spriteBatch.End();
		}

19 Source : GameScreen.cs
with MIT License
from BrianPeek

public override void Draw(GameTime gameTime)
		{
			_spriteBatch.Begin();
				_spriteBatch.Draw(_background, Vector2.Zero, Color.White);
				_maze.Draw(gameTime, _spriteBatch);
				_player.Draw(gameTime, _spriteBatch);
				_enemy.Draw(gameTime, _spriteBatch);
				_scoreDisplay.Draw(gameTime, _spriteBatch);
				_getReady.Draw(gameTime, _spriteBatch);
				_gameOver.Draw(gameTime, _spriteBatch);
				_livesDisplay.Draw(gameTime, _spriteBatch);
				_pauseDialog.Draw(gameTime, _spriteBatch);

				if(MonsterGame.Instance.DebugMode)
				{
					FontManager.DrawString(_spriteBatch, "Col: " + _player.Column + ", Row: " + _player.Row + ", " + _maze.GetTile(_player.Row, _player.Column).TileType, Vector2.Zero, Color.White);
					FontManager.DrawString(_spriteBatch, "X: " + _player.Position.X + ", Y: " + _player.Position.Y, new Vector2(0, 40), Color.White);
					FontManager.DrawString(_spriteBatch, "L: " + _player.BoundingBox.Left + ", R: " + _player.BoundingBox.Right, new Vector2(0, 80), Color.White);
					FontManager.DrawString(_spriteBatch, "T: " + _player.BoundingBox.Top + ", B: " + _player.BoundingBox.Bottom, new Vector2(0, 120), Color.White);
					FontManager.DrawString(_spriteBatch, "W: " + _player.BoundingBox.Width + ", H: " + _player.BoundingBox.Height, new Vector2(0, 160), Color.White);
				}
			_spriteBatch.End();
		}

19 Source : LeaderboardScreen.cs
with MIT License
from BrianPeek

public override void Draw(GameTime gameTime)
		{
			Vector2 linePos = Vector2.Zero;

			_spriteBatch.Begin();
				_spriteBatch.Draw(_background, Vector2.Zero, Color.White);
				if(_leaderboardData == null)
					FontManager.DrawShadowString(_spriteBatch, FontSize.Large, "Loading...", new Vector2(800, 320), Vector2.Zero, 1.0f, Color.White, Color.Black);
				else
				{
					foreach(LeaderboardItem li in _leaderboardData.Items)
					{
						FontManager.DrawString(_spriteBatch, FontSize.Large, li.Rank.ToString(), new Vector2(420, 320) + linePos, Vector2.Zero, 1.0f, Color.White);
						FontManager.DrawString(_spriteBatch, FontSize.Large, li.Gamertag, new Vector2(600, 320) + linePos, Vector2.Zero, 1.0f, Color.White);
						FontManager.DrawString(_spriteBatch, FontSize.Large, li.Value, new Vector2(1360, 320) + linePos, Vector2.Zero, 1.0f, Color.White);
						linePos += new Vector2(0, 80);
					}
				}
			_spriteBatch.End();
		}

19 Source : TitleScreen.cs
with MIT License
from BrianPeek

public override void Draw(GameTime gameTime)
		{
			Game.GraphicsDevice.Clear(Color.Black);
			_spriteBatch.Begin();
				_spriteBatch.Draw(_replacedleScreen, Vector2.Zero, Color.White);
				for(int i = 0; i < _menuItems.Count; i++)
					_spriteBatch.Draw((_selectedIndex == i) ? _menuItems[i].On : _menuItems[i].Off, MenuPosition + new Vector2(0, (i*_menuItems[i].On.Height)), Color.White);

				_gamerCard.Draw(gameTime, _spriteBatch);
			_spriteBatch.End();
		}

19 Source : Game1.cs
with MIT License
from craftworkgames

protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            _spriteBatch.Begin();
            _spriteBatch.DrawString(_spriteFont, "Hello MonoGame!", new Vector2(100, 100), Color.White);
            _spriteBatch.End();

            base.Draw(gameTime);
        }

19 Source : HudSystem.cs
with MIT License
from craftworkgames

public void Draw(GameTime gameTime)
        {
            _spriteBatch.Begin();
            _spriteBatch.FillRectangle(0, 0, 800, 20, Color.Black * 0.4f);
            _spriteBatch.DrawString(_font, $"enreplacedies: {_world.EnreplacedyCount}", Vector2.One, Color.White);
            _spriteBatch.End();
        }

19 Source : RenderSystem.cs
with MIT License
from craftworkgames

public override void Draw(GameTime gameTime)
        {
            _graphicsDevice.Clear(Color.DarkBlue * 0.2f);
            _spriteBatch.Begin(samplerState: SamplerState.PointClamp);

            foreach (var enreplacedy in ActiveEnreplacedies)
            {
                var transform = _transformMapper.Get(enreplacedy);
                var raindrop = _raindropMapper.Get(enreplacedy);

                _spriteBatch.FillRectangle(transform.Position, new Size2(raindrop.Size, raindrop.Size), Color.LightBlue);
            }

            _spriteBatch.End();
        }

19 Source : BitmapFontsDemo.cs
with MIT License
from craftworkgames

protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            _spriteBatch.Begin(
                samplerState: SamplerState.LinearClamp,
                blendState: BlendState.AlphaBlend,
                transformMatrix: _viewportAdapter.GetScaleMatrix());
            _spriteBatch.Draw(_backgroundTexture, _viewportAdapter.BoundingRectangle, Color.DarkBlue);

            const string helloWorld = "The quick brown fox jumps over the lazy dog\nThe lazy dog jumps back over the quick brown fox";

            var position = new Point2(400, 140);
            var offset = new Vector2(0, 50);
            var scale = Vector2.One;
            var color = Color.White;
            var rotation = 0;//MathHelper.Pi/64f;

            // bitmap font
            var bitmapFontSize = _bitmapFontImpact.MeasureString(helloWorld);
            var bitmapFontOrigin = (Point2)(bitmapFontSize / 2f);

            _spriteBatch.DrawString(
                bitmapFont: _bitmapFontImpact,
                text: helloWorld,
                position: position + offset,
                color: color,
                rotation: rotation,
                origin: bitmapFontOrigin,
                scale: scale,
                effect: SpriteEffects.None,
                layerDepth: 0);

            _spriteBatch.DrawRectangle(position - bitmapFontOrigin + offset, bitmapFontSize, Color.Red);

            var bitmapFontMontserratSize = _bitmapFontMontserrat.MeasureString(helloWorld);
            var bitmapFontMontserratOrigin = bitmapFontMontserratSize / 2f;

            _spriteBatch.DrawString(
                bitmapFont: _bitmapFontMontserrat,
                text: helloWorld,
                position: position + offset * 3,
                color: color,
                rotation: rotation,
                origin: bitmapFontMontserratOrigin,
                scale: scale,
                effect: SpriteEffects.None,
                layerDepth: 0,
                clippingRectangle: _clippingRectangle);

            _spriteBatch.DrawRectangle(_clippingRectangle, Color.White);
            _spriteBatch.DrawRectangle(position - bitmapFontMontserratOrigin + offset * 3, bitmapFontMontserratSize, Color.Green);

            _spriteBatch.DrawString(_bitmapFontMonospaced, "Hello Monospaced Fonts!", new Vector2(100, 400), Color.White);

            _spriteBatch.End();

            base.Draw(gameTime);
        }

19 Source : CameraDemo.cs
with MIT License
from craftworkgames

protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // the camera produces a view matrix that can be applied to any sprite batch
            var transformMatrix = _camera.GetViewMatrix(Vector2.Zero);
            _spriteBatch.Begin(transformMatrix: transformMatrix);
            _spriteBatch.Draw(_backgroundSky, Vector2.Zero, Color.White);
            _spriteBatch.Draw(_backgroundClouds, new Vector2(-_cloudsOffset, 0), Color.White);
            _spriteBatch.Draw(_backgroundClouds, new Vector2(_cloudsOffset, 10), Color.White);
            _spriteBatch.End();

            for (var layerIndex = 0; layerIndex < 4; layerIndex++)
            {
                // different layers can have a parallax factor applied for a nice depth effect
                var parallaxFactor = Vector2.One * (0.25f * layerIndex);
                var viewMatrix = _camera.GetViewMatrix(parallaxFactor);
                _spriteBatch.Begin(transformMatrix: viewMatrix);

                for (var repeatIndex = -3; repeatIndex <= 3; repeatIndex++)
                {
                    var texture = _backgroundHills[layerIndex];
                    var position = new Vector2(repeatIndex * texture.Width, 0);
                    _spriteBatch.Draw(texture, position, Color.White);
                }

                _spriteBatch.End();
            }

            // not all sprite batches need to be affected by the camera
            var rectangle = _camera.BoundingRectangle;
            var stringBuilder = new StringBuilder();
            stringBuilder.AppendLine($"WASD: Move [{_camera.Position.X:0}, {_camera.Position.Y:0}]");
            stringBuilder.AppendLine($"EQ: Rotate [{MathHelper.ToDegrees(_camera.Rotation):0.00}]");
            stringBuilder.AppendLine($"RF: Zoom [{_camera.Zoom:0.00}]");
            stringBuilder.AppendLine($"World Pos: [{_worldPosition.X:0}, {_worldPosition.Y:0}]");
            stringBuilder.AppendLine($"Bounds: [{rectangle.X:0}, {rectangle.Y:0}, {rectangle.Width:0}, {rectangle.Height:0}]");

            _spriteBatch.Begin(blendState: BlendState.AlphaBlend);
            _spriteBatch.DrawString(_bitmapFont, stringBuilder.ToString(), new Vector2(5, 5), Color.DarkBlue);
            _spriteBatch.End();

            base.Draw(gameTime);
        }

19 Source : CollisionDemo.cs
with MIT License
from craftworkgames

protected override void Draw(GameTime gameTime)
        {
            _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp);
            foreach (var actor in _actors)
            {
                actor.Draw(_spriteBatch);
            }
            _spriteBatch.End();

            base.Draw(gameTime);
        }

19 Source : ViewportAdaptersDemo.cs
with MIT License
from craftworkgames

protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            // when rendering sprites, you'll always work within the bounds of the virtual width and height
            // specified when setting up the viewport adapter. The default MonoGame window is 800x480.
            var destinationRectangle = new Rectangle(0, 0, 800, 480);

            _spriteBatch.Begin(transformMatrix: _currentViewportAdapter.GetScaleMatrix());
            _spriteBatch.Draw(_backgroundTexture, destinationRectangle, Color.White);
            _spriteBatch.DrawString(_bitmapFont, $"Press D: {typeof(DefaultViewportAdapter).Name}", new Vector2(49, 40), Color.White);
            _spriteBatch.DrawString(_bitmapFont, $"Press S: {typeof(ScalingViewportAdapter).Name}", new Vector2(49, 40 + _bitmapFont.LineHeight * 1), Color.White);
            _spriteBatch.DrawString(_bitmapFont, $"Press B: {typeof(BoxingViewportAdapter).Name}", new Vector2(49, 40 + _bitmapFont.LineHeight * 2), Color.White);
            _spriteBatch.DrawString(_bitmapFont, $"Current: {_currentViewportAdapter.GetType().Name}", new Vector2(49, 40 + _bitmapFont.LineHeight * 4), Color.Black);
            _spriteBatch.DrawString(_bitmapFont, @"Try resizing the window", new Vector2(49, 40 + _bitmapFont.LineHeight * 6), Color.Black);
            _spriteBatch.DrawString(_bitmapFont, $"Mouse: {_mousePosition}", new Vector2(49, 40 + _bitmapFont.LineHeight * 8), Color.Black);
            _spriteBatch.End();

            base.Draw(gameTime);
        }

19 Source : PongGameScreen.cs
with MIT License
from craftworkgames

public override void Draw(GameTime gameTime)
        {
            _spriteBatch.Begin(samplerState: SamplerState.PointClamp);
            _spriteBatch.Draw(_court, new Rectangle(0, 0, ScreenWidth, ScreenHeight), Color.White);

            DrawScores();

            _spriteBatch.Draw(_redPaddle.Sprite, _redPaddle.Position, _redPaddle.Rotation, _redPaddle.Scale);
            _spriteBatch.Draw(_bluePaddle.Sprite, _bluePaddle.Position, _bluePaddle.Rotation, _bluePaddle.Scale);
            _spriteBatch.Draw(_ball.Sprite, _ball.Position, _ball.Rotation, _ball.Scale); 
            _spriteBatch.End();
        }

19 Source : Game1.cs
with MIT License
from craftworkgames

protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            // background
            var sourceRectangle = new Rectangle(0, 0, _viewportAdapter.VirtualWidth, _viewportAdapter.VirtualHeight);
            sourceRectangle.Offset(_camera.Position * new Vector2(0.1f));

            _spriteBatch.Begin(samplerState: SamplerState.PointWrap, transformMatrix: _viewportAdapter.GetScaleMatrix());
            _spriteBatch.Draw(_backgroundTexture, Vector2.Zero, sourceRectangle, Color.White);
            _spriteBatch.DrawString(_font, $"{_score}", Vector2.One, Color.White);
            _spriteBatch.End();

            // enreplacedies
            _spriteBatch.Begin(samplerState: SamplerState.PointClamp, blendState: BlendState.AlphaBlend, transformMatrix: _camera.GetViewMatrix());
            _enreplacedyManager.Draw(_spriteBatch);
            _spriteBatch.End();

            _spriteBatch.Begin(transformMatrix: _camera.GetViewMatrix());



            _spriteBatch.End();

            base.Draw(gameTime);
        }

19 Source : GameMain.cs
with MIT License
from craftworkgames

protected override void Draw(GameTime gameTime)
        {
            _fpsCounter.Draw(gameTime);
            var fps = $"FPS: {_fpsCounter.FramesPerSecond}";

            GraphicsDevice.Clear(Color.Black);

            _spriteBatch.Begin();

            _world.Draw(gameTime);

            _spriteBatch.DrawString(_font, fps, new Vector2(16, 16), Color.White);

//#if DEBUG
//            var enreplacedyCount = $"Active Enreplacedies Count: {_enreplacedyManager.ActiveEnreplacediesCount}";
//            //var removedEnreplacedyCount = $"Removed Enreplacedies TotalCount: {_ecs.TotalEnreplacediesRemovedCount}";
//            var totalEnreplacedyCount = $"Allocated Enreplacedies Count: {_enreplacedyManager.TotalEnreplacediesCount}";

//            _spriteBatch.DrawString(_font, enreplacedyCount, new Vector2(16, 62), Color.White);
//            _spriteBatch.DrawString(_font, totalEnreplacedyCount, new Vector2(16, 92), Color.White);
//            //_spriteBatch.DrawString(_font, removedEnreplacedyCount, new Vector2(32, 122), Color.Yellow);
//#endif

            _spriteBatch.End();
        }

19 Source : MainWindowViewModel.cs
with MIT License
from craftworkgames

public override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            _spriteBatch.Begin();
            _spriteBatch.Draw(_texture, _position, null, Color.White, _rotation, _origin, _scale, SpriteEffects.None, 0f);
            _spriteBatch.End();
        }

19 Source : InputListenersDemo.cs
with MIT License
from craftworkgames

protected override void Draw(GameTime gameTime)
        {
            _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, transformMatrix: _camera.GetViewMatrix());
            _spriteBatch.Draw(_backgroundTexture, new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height), Color.DarkSlateGray);

            for (var i = 0; i < _logLines.Count; i++)
            {
                var logLine = _logLines[i];
                _spriteBatch.DrawString(_bitmapFont, logLine, new Vector2(4, i * _bitmapFont.LineHeight), Color.LightGray * 0.2f);
            }

            var textInputY = 14 * _bitmapFont.LineHeight - 2;
            var position = new Point2(4, textInputY);
            var stringRectangle = _bitmapFont.GetStringRectangle(_typedString, position);

            _spriteBatch.DrawString(_bitmapFont, _typedString, position, Color.White);

            if (_isCursorVisible)
                _spriteBatch.DrawString(_bitmapFont, "_", new Vector2(stringRectangle.Width, textInputY), Color.White);

            _spriteBatch.End();

            base.Draw(gameTime);
        }

19 Source : ParticlesDemo.cs
with MIT License
from craftworkgames

protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            _spriteBatch.Begin(blendState: BlendState.AlphaBlend, transformMatrix: _camera.GetViewMatrix());
            _spriteBatch.Draw(_particleEffect);
            _spriteBatch.Draw(_sprite, _transform.Position, _transform.Rotation, _transform.Scale);
            _spriteBatch.End();

            base.Draw(gameTime);
        }

19 Source : TitleScreen.cs
with MIT License
from craftworkgames

public override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Magenta);

            _spriteBatch.Begin(samplerState: SamplerState.PointClamp);
            _spriteBatch.Draw(_background, new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height), Color.White);
            _spriteBatch.End();
        }

19 Source : TiledMapsDemo.cs
with MIT License
from craftworkgames

private void DrawText()
        {
            var textColor = Color.Black;
            _spriteBatch.Begin(samplerState: SamplerState.PointClamp, blendState: BlendState.AlphaBlend);

            var baseTextPosition = new Point2(5, 0);
            var textPosition = baseTextPosition;
            _spriteBatch.DrawString(_bitmapFont,
                $"Map: {_map.Name}; {_map.TileLayers.Count} tile layer(s) @ {_map.Width}x{_map.Height} tiles, {_map.ImageLayers.Count} image layer(s)",
                textPosition, textColor);

            // we can safely get the metrics without worrying about spritebatch interfering because spritebatch submits on End()
            textPosition = baseTextPosition + new Vector2(0, _bitmapFont.LineHeight * 1);
            _spriteBatch.DrawString(_bitmapFont, $"Camera Position: (x={_camera.Position.X}, y={_camera.Position.Y})",
                textPosition, textColor);

            if (!_showHelp)
            {
                _spriteBatch.DrawString(_bitmapFont, "H: Show help", new Vector2(5, _bitmapFont.LineHeight * 2),
                    textColor);
            }
            else
            {
                textPosition = baseTextPosition + new Vector2(0, _bitmapFont.LineHeight * 2);
                _spriteBatch.DrawString(_bitmapFont, "H: Hide help", textPosition, textColor);
                textPosition = baseTextPosition + new Vector2(0, _bitmapFont.LineHeight * 3);
                _spriteBatch.DrawString(_bitmapFont, "WASD/Arrows: Pan camera", textPosition, textColor);
                textPosition = baseTextPosition + new Vector2(0, _bitmapFont.LineHeight * 4);
                _spriteBatch.DrawString(_bitmapFont, "RF: Zoom camera in / out", textPosition, textColor);
                textPosition = baseTextPosition + new Vector2(0, _bitmapFont.LineHeight * 5);
                _spriteBatch.DrawString(_bitmapFont, "Z: Move camera to the origin", textPosition, textColor);
                textPosition = baseTextPosition + new Vector2(0, _bitmapFont.LineHeight * 6);
                _spriteBatch.DrawString(_bitmapFont, "X: Move camera to look at the origin", textPosition, textColor);
                textPosition = baseTextPosition + new Vector2(0, _bitmapFont.LineHeight * 7);
                _spriteBatch.DrawString(_bitmapFont, "C: Move camera to look at center of the map", textPosition,
                    textColor);
                textPosition = baseTextPosition + new Vector2(0, _bitmapFont.LineHeight * 8);
                _spriteBatch.DrawString(_bitmapFont, "Tab: Cycle through maps", textPosition, textColor);
            }

            _spriteBatch.End();
        }

19 Source : RenderSystem.cs
with MIT License
from craftworkgames

public override void Draw(GameTime gameTime)
        {
            _spriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: _camera.GetViewMatrix());

            foreach (var enreplacedy in ActiveEnreplacedies)
            {
                var sprite = _animatedSpriteMapper.Has(enreplacedy)
                    ? _animatedSpriteMapper.Get(enreplacedy)
                    : _spriteMapper.Get(enreplacedy);
                var transform = _transforMapper.Get(enreplacedy);

                if(sprite is AnimatedSprite animatedSprite)
                    animatedSprite.Update(gameTime.GetElapsedSeconds());

                _spriteBatch.Draw(sprite, transform);

            }

            _spriteBatch.End();
        }

19 Source : SpriteEditorViewModel.cs
with MIT License
from craftworkgames

public override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            if (Texture == null)
                return;

            // main texture
            var boundingRectangle = TextureBounds;

            _spriteBatch.Begin(blendState: BlendState.AlphaBlend, samplerState: SamplerState.PointWrap, transformMatrix: Camera.GetViewMatrix());
            _spriteBatch.Draw(_backgroundTexture, sourceRectangle: boundingRectangle, destinationRectangle: boundingRectangle, color: Color.White);

            foreach (var keyFrame in SelectedKeyFrames)
            {
                var keyFrameRectangle = GetFrameRectangle(keyFrame.Index);
                _spriteBatch.FillRectangle(keyFrameRectangle, Color.CornflowerBlue * 0.5f);
            }

            if (SelectedAnimation != null)
            {
                foreach (var keyFrame in SelectedAnimation.KeyFrames)
                {
                    var keyFrameRectangle = GetFrameRectangle(keyFrame.Index);
                    _spriteBatch.FillRectangle(keyFrameRectangle, Color.Gray * 0.25f);
                }
            }

            _spriteBatch.Draw(Texture, sourceRectangle: boundingRectangle, destinationRectangle: boundingRectangle, color: Color.White);

            // highlighter
            if (TileWidth > 1 && TileHeight > 1)
            {
                for (var y = 0; y <= Texture.Height; y += TileHeight)
                    _spriteBatch.DrawLine(0, y, boundingRectangle.Width, y, Color.White * 0.5f);

                for (var x = 0; x <= Texture.Width; x += TileWidth)
                    _spriteBatch.DrawLine(x, 0, x, boundingRectangle.Height, Color.White * 0.5f);

                if (boundingRectangle.Contains(WorldPosition))
                {
                    var cx = (int)(WorldPosition.X / TileWidth);
                    var cy = (int)(WorldPosition.Y / TileHeight);

                    _spriteBatch.FillRectangle(cx * TileWidth, cy * TileHeight, TileWidth, TileHeight, Color.CornflowerBlue * 0.5f);
                }
            }

            _spriteBatch.End();

            // animation preview
            if (SelectedAnimation != null && SelectedAnimation.KeyFrames.Any())
            {
                var frame = GetCurrentFrame();
                var sourceRectangle = GetFrameRectangle(frame.Index);
                var previewRectangle = GetPreviewRectangle();

                _spriteBatch.Begin(blendState: BlendState.AlphaBlend, samplerState: SamplerState.PointWrap);
                _spriteBatch.Draw(_backgroundTexture, previewRectangle, null, Color.White);
                _spriteBatch.DrawRectangle(previewRectangle, Color.White * 0.5f);
                _spriteBatch.Draw(Texture, previewRectangle, sourceRectangle, Color.White);
                _spriteBatch.End();
            }

            // debug text
            var frameIndex = GetFrameIndex();

            if (frameIndex.HasValue)
            {
                var frameRectangle = GetFrameRectangle(frameIndex.Value);
                _spriteBatch.Begin(blendState: BlendState.AlphaBlend, samplerState: SamplerState.PointWrap);
                _spriteBatch.DrawString(_spriteFont, $"frame: {frameIndex} ({frameRectangle.X}, {frameRectangle.Y})", Vector2.Zero, Color.White);
                _spriteBatch.End();
            }
        }

19 Source : AnimationsDemo.cs
with MIT License
from craftworkgames

protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            //_spriteBatch.Begin(transformMatrix: Camera.GetViewMatrix(), samplerState: SamplerState.PointClamp);
            //_zombie.Draw(_spriteBatch);
            ////_spriteBatch.Draw(_fireballSprite);
            //_spriteBatch.End();

            _spriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: Camera.GetViewMatrix());
            _spriteBatch.Draw(_motwSprite, _motwPosition);
            _spriteBatch.Draw(_fireballSprite, new Vector2(200, 100));
            //_spriteBatch.Draw(_zombie, new Vector2(300, 100));
            _spriteBatch.End();

            base.Draw(gameTime);
        }

19 Source : BatchingDemo.cs
with MIT License
from craftworkgames

private void DrawSpritesWithSpriteBatch()
        {
            _effect.Projection = _projectionMatrix;
            _effect.View = _viewMatrix;
            _spriteBatch.Begin(SpriteSortMode.Texture, effect: _effect);

            // ReSharper disable once ForCanBeConvertedToForeach
            for (var index = 0; index < _sprites.Length; index++)
            {
                var sprite = _sprites[index];
                _spriteBatch.Draw(sprite.Texture, sprite.Position, null, sprite.Color, sprite.Rotation, _spriteOrigin, _spriteScale, SpriteEffects.None, 0);
            }

            _spriteBatch.End();
        }

19 Source : SceneGraphsDemo.cs
with MIT License
from craftworkgames

protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            _spriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: _camera.GetViewMatrix());
            _spriteBatch.Draw(_sceneGraph);
            _spriteBatch.FillRectangle(0, 266, 800, 240, Color.DarkOliveGreen);
            _spriteBatch.FillRectangle(200, 0, 5, 480, Color.DarkOliveGreen);
            _spriteBatch.FillRectangle(595, 0, 5, 480, Color.DarkOliveGreen);

            if (_hoveredNode != null)
            {
                var boundingRectangle = _hoveredNode.BoundingRectangle;
                _spriteBatch.DrawRectangle(boundingRectangle, Color.Black);
            }

            _spriteBatch.End();

            _spriteBatch.Begin();

            if (_hoveredNode != null)
                _spriteBatch.DrawString(_bitmapFont, _hoveredNode.Name, new Vector2(14, 2), Color.White);

            _spriteBatch.End();

            base.Draw(gameTime);
        }

19 Source : SpritesDemo.cs
with MIT License
from craftworkgames

protected override void Draw(GameTime gameTime)
        {
            _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp);
            _spriteBatch.Draw(_backgroundTexture, new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height), Color.White);
            //_spriteBatch.Draw(_axeSprite);
            //_spriteBatch.Draw(_spikeyBallSprite);
            //_spriteBatch.Draw(_particleSprite0);
            //_spriteBatch.Draw(_particleSprite1);

            // clipping test
            _spriteBatch.Draw(_clippingTextureRegion, new Rectangle(50, 50, 128, 128), Color.White, clippingRectangle: null);
            _spriteBatch.Draw(_clippingTextureRegion, new Rectangle(50, 250, 512, 512), Color.White, clippingRectangle: _clippingRectangle);
            _spriteBatch.DrawRectangle(_clippingRectangle.ToRectangleF(), Color.White);

            _spriteBatch.Draw(_apple, new Vector2(100, 100));

            _spriteBatch.End();

            base.Draw(gameTime);
        }

19 Source : MainGame.cs
with MIT License
from craftworkgames

protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            _spriteBatch.Begin(samplerState: SamplerState.PointClamp);

            _spriteBatch.FillRectangle(Linear.X, Linear.Y, Size.X, Size.X, Color.Red);
            _spriteBatch.FillRectangle(Quadratic.X, Quadratic.Y, Size.X, Size.X, Color.Green);
            _spriteBatch.FillRectangle(Exponential.X, Exponential.Y, Size.X, Size.X, Color.Blue);
            _spriteBatch.FillRectangle(Bounce.X, Bounce.Y, Size.X, Size.X, Color.DarkOrange);
            _spriteBatch.FillRectangle(Back.X, Back.Y, Size.X, Size.X, Color.Purple);
            _spriteBatch.FillRectangle(Elastic.X, Elastic.Y, Size.X, Size.X, Color.Yellow);

            _spriteBatch.DrawString(_bitmapFont, $"{_tweener.AllocationCount}", Vector2.One, Color.WhiteSmoke);

            _spriteBatch.End();

            base.Draw(gameTime);
        }

19 Source : Game.cs
with MIT License
from dotnet-ad

protected override void Draw(GameTime gameTime)
		{
			GraphicsDevice.Clear(Color.Black);

			spriteBatch.Begin();

			var borders = new Color(1.0f, 1.0f, 1.0f, 0.2f);

			// Full texture
			spriteBatch.Draw(this.sheet.Texture, new Vector2(0, 0));
			spriteBatch.DrawRectangle(this.sheet.Texture.Bounds, borders);

			// Animation
			spriteBatch.Draw(this.anim, new Vector2(64, 64 + this.sheet.Texture.Height));
			this.font.Draw(spriteBatch, new Vector2(12, 12 + this.sheet.Texture.Height), $"{animIndex}", Color.White);

			// Frames in full texture
			for (int ia = 0; ia < anim.Frames.Length; ia++)
			{
				var a = anim.Frames[ia];

				spriteBatch.DrawRectangle(a.Area, borders);
				spriteBatch.DrawCross(a.Area.Location.ToVector2() + a.Origin.ToVector2(), borders);
				this.font.Draw(spriteBatch, a.Area.Location.ToVector2() + new Vector2(4, 4), $"{ia}", borders);
			}

			//Mouse
			const int mouseGrid = 16;
			var mx = (this.state.X / mouseGrid) * mouseGrid;
			var my = (this.state.Y / mouseGrid) * mouseGrid;
			spriteBatch.DrawLine(0, my, this.GraphicsDevice.Viewport.Width, my, Color.Green);
			spriteBatch.DrawLine(mx, 0, mx, this.GraphicsDevice.Viewport.Height, Color.Blue);
			this.font.Draw(spriteBatch, new Vector2(mx, my) + new Vector2(32,32), $"({mx},{my})", borders);

			spriteBatch.End();

			base.Draw(gameTime);
		}

19 Source : Sample.cs
with MIT License
from dotnet-ad

protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);

            this.spriteBatch.Begin();
            this.arm.Draw(this.spriteBatch);
            this.spriteBatch.End();

            base.Draw(gameTime);
        }

19 Source : Painter.cs
with MIT License
from egges

protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.White);
        spriteBatch.Begin();
        spriteBatch.Draw(background, Vector2.Zero, Color.White);
        cannon.Draw(gameTime, spriteBatch);
        spriteBatch.End();
    }

19 Source : GameWorld.cs
with MIT License
from egges

public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
    {
        spriteBatch.Begin();
        spriteBatch.Draw(background, Vector2.Zero, Color.White);
        ball.Draw(gameTime, spriteBatch);
        cannon.Draw(gameTime, spriteBatch);
        can1.Draw(gameTime, spriteBatch);
        can2.Draw(gameTime, spriteBatch);
        can3.Draw(gameTime, spriteBatch);
        spriteBatch.End();
    }

19 Source : GameWorld.cs
with MIT License
from egges

public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
    {
        spriteBatch.Begin();
        spriteBatch.Draw(background, Vector2.Zero, Color.White);
        ball.Draw(gameTime, spriteBatch);
        cannon.Draw(gameTime, spriteBatch);
        can1.Draw(gameTime, spriteBatch);
        can2.Draw(gameTime, spriteBatch);
        can3.Draw(gameTime, spriteBatch);
        for (int i = 0; i < lives; i++)
        {
            spriteBatch.Draw(livesSprite, new Vector2(i * livesSprite.Width + 15, 20), Color.White);
        }

        if (IsGameOver)
        {
            spriteBatch.Draw(gameover, new Vector2(Painter.ScreenSize.X - gameover.Width, Painter.ScreenSize.Y - gameover.Height) / 2, Color.White);
        }

        spriteBatch.End();
    }

19 Source : Balloon.cs
with MIT License
from egges

protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.White);
        spriteBatch.Begin();
        spriteBatch.Draw(background, Vector2.Zero, Color.White);
        spriteBatch.Draw(balloon, balloonPosition, Color.White);
        spriteBatch.End();
    }

19 Source : Balloon.cs
with MIT License
from egges

protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.White);
        spriteBatch.Begin();
        spriteBatch.Draw(background, Vector2.Zero, Color.White);
        spriteBatch.Draw(balloon, balloonPosition, null, Color.White, 0.0f, balloonOrigin, 1.0f, SpriteEffects.None, 0);
        spriteBatch.End();
    }

19 Source : Painter.cs
with MIT License
from egges

protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.White);
        spriteBatch.Begin();
        spriteBatch.Draw(background, Vector2.Zero, Color.White);
        spriteBatch.Draw(cannonBarrel, barrelPosition, null, Color.White, angle, barrelOrigin, 1.0f, SpriteEffects.None, 0);
        spriteBatch.End();
    }

19 Source : GameWorld.cs
with MIT License
from egges

public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
    {
        spriteBatch.Begin();
        spriteBatch.Draw(background, Vector2.Zero, Color.White);
        ball.Draw(gameTime, spriteBatch);
        cannon.Draw(gameTime, spriteBatch);
        spriteBatch.End();
    }

19 Source : ExtendedGame.cs
with MIT License
from egges

protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            // start drawing sprites, applying the scaling matrix
            spriteBatch.Begin(SpriteSortMode.FrontToBack, null, null, null, null, null, spriteScale);

            // let the game world draw itself
            GameStateManager.Draw(gameTime, spriteBatch);

            spriteBatch.End();
        }

19 Source : SpriteDrawing.cs
with MIT License
from egges

protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.White);
        spriteBatch.Begin();
        spriteBatch.Draw(balloon, Vector2.Zero, Color.White);
        spriteBatch.End();
    }

19 Source : Painter.cs
with MIT License
from egges

protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.White);
        spriteBatch.Begin();
        spriteBatch.Draw(background, Vector2.Zero, Color.White);
        spriteBatch.Draw(cannonBarrel, barrelPosition, null, Color.White, angle, barrelOrigin, 1.0f, SpriteEffects.None, 0);
        spriteBatch.Draw(currentColor, barrelPosition, null, Color.White, 0f, colorOrigin, 1.0f, SpriteEffects.None, 0);
        spriteBatch.End();
    }

19 Source : GameWorld.cs
with MIT License
from egges

public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
    {
        spriteBatch.Begin();
        spriteBatch.Draw(background, Vector2.Zero, Color.White);
        cannon.Draw(gameTime, spriteBatch);
        spriteBatch.End();
    }

19 Source : GameWorld.cs
with MIT License
from egges

public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
    {
        spriteBatch.Begin();
        spriteBatch.Draw(background, Vector2.Zero, Color.White);
        ball.Draw(gameTime, spriteBatch);
        cannon.Draw(gameTime, spriteBatch);
        can1.Draw(gameTime, spriteBatch);
        can2.Draw(gameTime, spriteBatch);
        can3.Draw(gameTime, spriteBatch);
        for (int i = 0; i < lives; i++)
        {
            spriteBatch.Draw(livesSprite, new Vector2(i * livesSprite.Width + 15, 20), Color.White);
        }
        if (lives <= 0)
        {
            spriteBatch.Draw(gameover, new Vector2(Painter.Screen.X - gameover.Width, Painter.Screen.Y - gameover.Height) / 2, Color.White);
        }
        spriteBatch.End();
    }

19 Source : GameWorld.cs
with MIT License
from egges

public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
    {
        spriteBatch.Begin();

        // draw the background and score bar
        spriteBatch.Draw(background, Vector2.Zero, Color.White);
        spriteBatch.Draw(scoreBar, new Vector2(10, 10), Color.White);

        // draw all game objects
        ball.Draw(gameTime, spriteBatch);
        cannon.Draw(gameTime, spriteBatch);
        can1.Draw(gameTime, spriteBatch);
        can2.Draw(gameTime, spriteBatch);
        can3.Draw(gameTime, spriteBatch);

        // draw the score
        spriteBatch.DrawString(gameFont, "Score: " + Score, new Vector2(20, 18), Color.White);

        // draw the number of lives
        for (int i = 0; i < lives; i++)
            spriteBatch.Draw(livesSprite, new Vector2(i * livesSprite.Width + 15, 60), Color.White);

        // if the game is over, draw the game-over sprite
        if (lives <= 0)
            spriteBatch.Draw(gameover, new Vector2(Painter.ScreenSize.X - gameover.Width, Painter.ScreenSize.Y - gameover.Height) / 2, Color.White);

        spriteBatch.End();
    }

19 Source : JewelJam.cs
with MIT License
from egges

protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.Black);

        // start drawing sprites, applying the scaling matrix
        spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, spriteScale);

        // draw the background sprite
        spriteBatch.Draw(background, Vector2.Zero, Color.White);

        spriteBatch.End();
    }

19 Source : JewelJam.cs
with MIT License
from egges

protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.Black);

        // start drawing sprites, applying the scaling matrix
        spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, spriteScale);

        // draw the background sprite
        spriteBatch.Draw(background, Vector2.Zero, Color.White);

        // draw all jewels: one per grid cell
        for (int x = 0; x < GridWidth; x++)
        {
            for (int y = 0; y < GridHeight; y++)
            {
                // compute the world position for this grid cell
                Vector2 position = GridOffset + new Vector2(x,y) * CellSize;

                // the grid stores a number; draw the sprite replacedociated to that number
                int jewelIndex = grid[x, y];
                spriteBatch.Draw(jewels[jewelIndex], position, Color.White);
            }
        }
        spriteBatch.End();
    }

19 Source : ExtendedGame.cs
with MIT License
from egges

protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.Black);

        // start drawing sprites, applying the scaling matrix
        spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, spriteScale);

        // let all game objects draw themselves
        foreach (GameObject obj in gameWorld)
            obj.Draw(gameTime, spriteBatch);

        spriteBatch.End();
    }

19 Source : ExtendedGame.cs
with MIT License
from egges

protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.Black);

        // start drawing sprites, applying the scaling matrix
        spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, spriteScale);

        // let the game world draw itself
        gameWorld.Draw(gameTime, spriteBatch);

        spriteBatch.End();
    }

19 Source : GameWorld.cs
with MIT License
from egges

public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
    {
        spriteBatch.Begin();
        spriteBatch.Draw(background, Vector2.Zero, Color.White);
        ball.Draw(gameTime, spriteBatch);
        cannon.Draw(gameTime, spriteBatch);
        can1.Draw(gameTime, spriteBatch);
        can2.Draw(gameTime, spriteBatch);
        can3.Draw(gameTime, spriteBatch);
        for (int i = 0; i < lives; i++)
        {
            spriteBatch.Draw(livesSprite, new Vector2(i * livesSprite.Width + 15, 60), Color.White);
        }
        if (lives <= 0)
        {
            spriteBatch.Draw(gameOver, new Vector2(Painter.Screen.X - gameOver.Width, Painter.Screen.Y - gameOver.Height) / 2, Color.White);
        }
        spriteBatch.End();
    }

19 Source : GameWorld.cs
with MIT License
from egges

public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
    {
        spriteBatch.Begin();
        spriteBatch.Draw(background, Vector2.Zero, Color.White);
        spriteBatch.Draw(scoreBar, new Vector2(10, 10), Color.White);
        ball.Draw(gameTime, spriteBatch);
        cannon.Draw(gameTime, spriteBatch);
        can1.Draw(gameTime, spriteBatch);
        can2.Draw(gameTime, spriteBatch);
        can3.Draw(gameTime, spriteBatch);
        spriteBatch.DrawString(gameFont, "Score: " + score, new Vector2(20, 18), Color.White);
        for (int i = 0; i < lives; i++)
        {
            spriteBatch.Draw(livesSprite, new Vector2(i * livesSprite.Width + 15, 60), Color.White);
        }
        if (lives <= 0)
        {
            spriteBatch.Draw(gameOver, new Vector2(Painter.Screen.X - gameOver.Width, Painter.Screen.Y - gameOver.Height) / 2, Color.White);
        }
        spriteBatch.End();
    }

19 Source : Snow.cs
with MIT License
from egges

protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.White);
        spriteBatch.Begin();
        spriteBatch.Draw(background, Vector2.Zero, Color.White);
        foreach (Snowflake obj in snowflakes)
        {
            obj.Draw(gameTime, spriteBatch);
        }
        spriteBatch.End();
    }

See More Examples