/// <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); spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, camera.TranslationMatrix); grid.Draw(spriteBatch); hud.Draw(spriteBatch); // TODO: Add your drawing code here spriteBatch.End(); base.Draw(gameTime); }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.WhiteSmoke); spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); switch (TileGrid.GameState) { case GameStates.Menu: menuManager.Draw(spriteBatch); bannerManager.Draw(spriteBatch, true); break; case GameStates.Lobby: menuManager.Draw(spriteBatch); networkingManager.Draw(spriteBatch); bannerManager.Draw(spriteBatch, true); break; case GameStates.QuitGame: menuManager.Draw(spriteBatch); tileManager.Draw(spriteBatch); TileGrid.Draw(spriteBatch); bannerManager.Draw(spriteBatch, false); animationManager.Draw(spriteBatch); break; case GameStates.Playing: tileManager.Draw(spriteBatch); TileGrid.Draw(spriteBatch); bannerManager.Draw(spriteBatch, false); animationManager.Draw(spriteBatch); break; } fpsMonitor.Draw(spriteBatch); spriteBatch.End(); if (screenshotManager.NewShot) { screenshotManager.SaveScreenshot(); } base.Draw(gameTime); }
protected override void Draw() { GraphicsDevice.Clear(Color.LightGray); Vector2 oldPosition = _parentGrid.Position; Vector2 oldScale = _parentGrid.Scale; _parentGrid.Position = Vector2.Zero; _parentGrid.Scale = Vector2.One; _parentGrid.UpdateBoundingRect(); _parentGrid.Scale = new Vector2( (float)this.Size.Width / (float)_parentGrid.BoundingRect.Width, (float)this.Size.Height / (float)_parentGrid.BoundingRect.Height); _parentGrid.Draw(1 / 60f); SquidEditorForm.SwapCameraAndRenderScene(_camera); _parentGrid.Position = oldPosition; _parentGrid.Scale = oldScale; _parentGrid.UpdateBoundingRect(); }
public override void Draw(GameTime gameTime) { // This game has a blue background.Why? Because! ScreenManager.GraphicsDevice.Clear(ClearOptions.Target, Color.LightSkyBlue, 0, 0); tileGrid.Draw(spriteBatch); spriteBatch.Begin(); table.Draw(gameTime); spriteBatch.End(); // If the game is transitioning on or off, fade it out to black. //if (TransitionPosition > 0 || pauseAlpha > 0) //{ // float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2); // ScreenManager.FadeBackBufferToBlack(alpha); //} }
protected override void Draw() { DrawingManager.ViewPortSize = new Point(this.Width, this.Height); Update(1 / 60f); ParentEditor.ZoomBox.Camera.Position = new Vector2(-this.AutoScrollPosition.X, -this.AutoScrollPosition.Y); ParentEditor.ZoomBox.Camera.Update(1 / 60f); Vector2 sizeRatio = new Vector2( (float)this.Size.Width / ((float)this.Size.Width * ParentEditor.ZoomBox.Camera.Zoom.X), (float)this.Size.Height / ((float)this.Size.Height * ParentEditor.ZoomBox.Camera.Zoom.Y)); GraphicsDevice.Clear(Color.LightBlue); // Use SpriteSortMode.Immediate, so we can apply custom renderstates. _spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState); // Set the texture addressing mode to wrap, so we can repeat // many copies of our tiled checkerboard texture. GraphicsDevice.SamplerStates[0].AddressU = TextureAddressMode.Wrap; GraphicsDevice.SamplerStates[0].AddressV = TextureAddressMode.Wrap; Rectangle fullRect = new Rectangle(0, 0, this.Width, this.Height); // Draw a tiled crossed pattern in the background. _spriteBatch.Draw(_crossTexture, fullRect, fullRect, Color.White); _spriteBatch.Draw(_checkerTexture, new Rectangle(0, 0, (int)(_tileGrid.BoundingRect.Width * ParentEditor.ZoomBox.Camera.Zoom.X), (int)(_tileGrid.BoundingRect.Height * ParentEditor.ZoomBox.Camera.Zoom.Y)), new Rectangle(0, 0, (int)(_tileGrid.BoundingRect.Width * ParentEditor.ZoomBox.Camera.Zoom.X), (int)(_tileGrid.BoundingRect.Height * ParentEditor.ZoomBox.Camera.Zoom.Y)), Color.White); _spriteBatch.End(); this.AutoScrollMinSize = new System.Drawing.Size((int)(_tileGrid.BoundingRect.Width * ParentEditor.ZoomBox.Camera.Zoom.X), (int)(_tileGrid.BoundingRect.Height * ParentEditor.ZoomBox.Camera.Zoom.Y)); Vector2 pos = _tileGrid.Position; _tileGrid.Position = Vector2.Zero; _tileGrid.Pivot = Vector2.Zero; _tileGrid.Draw(1 / 60f); _tileGrid.Position = pos; //_camera.Position += _tileGrid.Position; if (PaintMode == TileGridPaintMode.Brush) { DrawBrushTileHighlight(new Color(25, 255, 100, 150)); } else if (PaintMode == TileGridPaintMode.Bucket) { DrawBrushTileHighlight(new Color(25, 100, 255, 150)); _brushSize = new Point(1, 1); } else if (PaintMode == TileGridPaintMode.Eraser) { DrawBrushTileHighlight(new Color(255, 0, 0, 150)); } else if (PaintMode == TileGridPaintMode.Edit) { foreach (Point tile in _selectedTiles) { DrawTileSelection(tile.X, tile.Y); } if (_isPastingTiles) { DrawPastingSelection(_drawPosPastingSelection.X, _drawPosPastingSelection.Y); } } if (_drawGrid == true) { DrawGridLines(); } MilkshakeForm.SwapCameraAndRenderScene(ParentEditor.ZoomBox.Camera); _parent.Update(1 / 60f); }
protected override void Draw() { DrawingManager.ViewPortSize = new Point(this.Width, this.Height); Update(1 / 60f); ParentEditor.ZoomBox.Camera.Position = new Vector2(-this.AutoScrollPosition.X, -this.AutoScrollPosition.Y); ParentEditor.ZoomBox.Camera.Update(1 / 60f); Vector2 sizeRatio = new Vector2( (float)this.Size.Width / ((float)this.Size.Width * ParentEditor.ZoomBox.Camera.Zoom.X), (float)this.Size.Height / ((float)this.Size.Height * ParentEditor.ZoomBox.Camera.Zoom.Y)); GraphicsDevice.Clear(Color.White); // Use SpriteSortMode.Immediate, so we can apply custom renderstates. _spriteBatch.Begin(SpriteSortMode.Immediate, null, SamplerState.LinearWrap, null, null); // Set the texture addressing mode to wrap, so we can repeat // many copies of our tiled checkerboard texture. Rectangle fullRect = new Rectangle(0, 0, this.Width, this.Height); // Draw a tiled crossed pattern in the background. _spriteBatch.Draw(_crossTexture, fullRect, fullRect, Color.White); _spriteBatch.Draw(_checkerTexture, new Rectangle(0, 0, (int)(_tileGrid.BoundingRect.Width * ParentEditor.ZoomBox.Camera.Zoom.X), (int)(_tileGrid.BoundingRect.Height * ParentEditor.ZoomBox.Camera.Zoom.Y)), new Rectangle(0, 0, (int)(_tileGrid.BoundingRect.Width * ParentEditor.ZoomBox.Camera.Zoom.X), (int)(_tileGrid.BoundingRect.Height * ParentEditor.ZoomBox.Camera.Zoom.Y)), Color.White); _spriteBatch.End(); this.AutoScrollMinSize = new System.Drawing.Size((int)(_tileGrid.BoundingRect.Width * ParentEditor.ZoomBox.Camera.Zoom.X), (int)(_tileGrid.BoundingRect.Height * ParentEditor.ZoomBox.Camera.Zoom.Y)); Vector2 pos = _tileGrid.Position; _tileGrid.Position = Vector2.Zero; _tileGrid.Pivot = Vector2.Zero; _tileGrid.Draw(1 / 60f); _tileGrid.Position = pos; //_camera.Position += _tileGrid.Position; if (PaintMode == TileGridPaintMode.Brush) { DrawBrushTileHighlight(new Color(25, 255, 100, 150)); } else if (PaintMode == TileGridPaintMode.Bucket) { DrawBrushTileHighlight(new Color(25, 100, 255, 150)); _brushSize = new Point(1, 1); } else if (PaintMode == TileGridPaintMode.Eraser) { DrawBrushTileHighlight(new Color(255, 0, 0, 150)); } else if (PaintMode == TileGridPaintMode.Edit) { foreach (Point tile in _selectedTiles) { DrawTileSelection(tile.X, tile.Y); } if (_isPastingTiles) { DrawPastingSelection(_drawPosPastingSelection.X, _drawPosPastingSelection.Y); } } else if (PaintMode == TileGridPaintMode.Passage) { for (int y = 0; y < _tileGrid.TileRows; ++y) { for (int x = 0; x < _tileGrid.TileCols; ++x) { Color fillColor; if (TileGrid.TileLayers[0].Tiles[x][y].Passable) { fillColor = new Color(80, 100, 150, 150); } else { fillColor = new Color(80, 0, 15, 150); } Vector2 position = new Vector2(x * TileGrid.TileSize.X * TileGrid.Scale.X, y * TileGrid.TileSize.Y * TileGrid.Scale.Y); Vector2 size = new Vector2(TileGrid.TileSize.X * TileGrid.Scale.X, TileGrid.TileSize.Y * TileGrid.Scale.Y); DrawingManager.DrawFilledRectangle(TileGrid.Layer, position, size, fillColor, TileGrid.BlendingType); } } } if (_drawGrid == true) { DrawGridLines(); } SquidEditorForm.SwapCameraAndRenderScene(ParentEditor.ZoomBox.Camera); _parent.Update(1 / 60f); }
public virtual void Draw(SpriteBatch spriteBatch) { WorldMesh.Draw(spriteBatch); DrawObjects(spriteBatch); }