public override void Draw(Graphics.Graphics graphics) { frameCounter++; SpriteFont fallbackFont = graphics.GetSpriteFontByName("fallback"); //Current screen should never be null. Previous could, however. graphics.GetSpriteBatch().DrawString(fallbackFont, $"CurrentScreen: {screenManager.CurrentScreen.ScreenName}", Vector2.Zero, Color.Black); if(screenManager.PreviousScreen != null) { graphics.GetSpriteBatch().DrawString(fallbackFont, $"PreviousScreen: {screenManager.PreviousScreen.ScreenName}", new Vector2(0, 16), Color.Black); } graphics.GetSpriteBatch().DrawString(fallbackFont, $"FPS: " + framerate, new Vector2(0, 64), Color.Black); if (screenManager.CurrentScreen != null && screenManager.CurrentScreen.GetType() == typeof(BlankScreen)) { var debugScreen = (BlankScreen)screenManager.CurrentScreen; //graphics.GetSpriteBatch().DrawString(fallbackFont, // $"Lights: " + debugScreen.LightsRenderer.Lights.Count(), new Vector2(0, 64 + 16), Color.Black); graphics.GetSpriteBatch().DrawString(fallbackFont, $"X-Velocity: " + debugScreen.TestEntity.xVelocity, new Vector2(0, 64 + 32), Color.Black); } graphics.GetSpriteBatch().DrawString(fallbackFont, $"Mouse Position: {Minecraft2D.InputHelper.MousePosition.ToString()}; Inside: {Minecraft2D.InputHelper.IsMouseInsideWindow()}" , new Vector2(0, 32), Color.Black); }
public override void Draw(Graphics.Graphics graphics) { graphics.GetSpriteBatch().Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone); graphics.GetGraphicsDeviceManager().GraphicsDevice.Clear(Color.Black); DrawBackground(graphics); DrawControls(graphics); DrawCursor(graphics); graphics.GetSpriteBatch().End(); }
public void Draw(Graphics.Graphics graphics) { graphics.GetGraphicsDeviceManager().GraphicsDevice.Clear(Color.CornflowerBlue); graphics.GetSpriteBatch().Begin(sortMode: Microsoft.Xna.Framework.Graphics.SpriteSortMode.Deferred, /*transformMatrix: Camera.Transformation(graphics.GetGraphicsDeviceManager().GraphicsDevice) ,*/ depthStencilState: DepthStencilState.None, samplerState: SamplerState.PointClamp); Map.Draw(graphics); int tx, ty; tx = (int)Math.Floor(Minecraft2D.InputHelper.MousePosition.X / Constants.TileSize); ty = (int)Math.Floor(Minecraft2D.InputHelper.MousePosition.Y / Constants.TileSize); if(Map.GetTileAtIndex(tx, ty) != null) graphics.GetSpriteBatch().Draw(GetRectangle(graphics), new Rectangle(tx * Constants.TileSize, ty * Constants.TileSize, Constants.TileSize, Constants.TileSize), Color.Gray * .32f); TestPlayer.Draw(graphics); graphics.GetSpriteBatch().End(); }
public new void Draw(Graphics.Graphics graphics) { DrawBaseScene(graphics); DrawLights(graphics); graphics.GetGraphicsDeviceManager().GraphicsDevice.Clear(Color.White); graphics.GetSpriteBatch().Begin(blendState: Lighted.Multiply, samplerState: SamplerState.PointClamp); var screenRect = graphics.ScreenRectangle(); graphics.GetSpriteBatch().Draw(BaseScene, screenRect, Color.White); ScreenRect = screenRect; if (RenderLights) graphics.GetSpriteBatch().Draw(LightScene, screenRect, Color.White); graphics.GetSpriteBatch().End(); }
public override void Draw(Graphics.Graphics graphics) { var texture = graphics.GetTexture2DByName(SheetName); graphics.GetSpriteBatch().Draw( texture, Position.ToRectangle(), Region, Color.White ); }
public void DrawBaseScene(Graphics.Graphics graphics) { graphics.GetGraphicsDeviceManager().GraphicsDevice.SetRenderTarget(BaseScene); graphics.GetGraphicsDeviceManager().GraphicsDevice.Clear(Color.CornflowerBlue); graphics.GetSpriteBatch().Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone, transformMatrix: Camera.Transformation(graphics.GetGraphicsDeviceManager().GraphicsDevice)); Map.Draw(graphics, Camera); //Draws the regular entites and their sprites and whatnot. ((List<IAnimatedEntity>)Entities).ForEach(entity => { entity.Draw(graphics); }); graphics.GetSpriteBatch().End(); graphics.GetGraphicsDeviceManager().GraphicsDevice.SetRenderTarget(null); }
public void DrawLights(Graphics.Graphics graphics) { graphics.GetGraphicsDeviceManager().GraphicsDevice.SetRenderTarget(LightScene); graphics.GetGraphicsDeviceManager().GraphicsDevice.Clear(AmbientLight); graphics.GetSpriteBatch().Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone, transformMatrix: Camera.Transformation(graphics.GetGraphicsDeviceManager().GraphicsDevice)); var texture = graphics.GetTexture2DByName("circle"); ((List<LightSource>)StaticLights).ForEach(light => { graphics.GetSpriteBatch().Draw( texture, light.Size, light.Color ); }); //The dynamic lights foreach (var entity in Entities.Where(x => x is IDynamicLightEntity)) { if (entity is IDynamicLightEntity) { var entityAsLight = (IDynamicLightEntity)entity; var drawingPoint = entityAsLight.Position.ToRectangle(); drawingPoint.Width = texture.Width; drawingPoint.Height = texture.Height; if (entityAsLight.LightSize != 1.0f) { drawingPoint.Width = (int)(drawingPoint.Width * entityAsLight.LightSize); drawingPoint.Height = (int)(drawingPoint.Height * entityAsLight.LightSize); } if (entityAsLight.LightOffset != null) { drawingPoint.X += (int)(entityAsLight.LightOffset.X - (drawingPoint.Width / 2)); drawingPoint.Y += (int)(entityAsLight.LightOffset.Y - (drawingPoint.Height / 2)); } graphics.GetSpriteBatch().Draw(texture, drawingPoint, entityAsLight.LightColor); } } graphics.GetSpriteBatch().End(); graphics.GetGraphicsDeviceManager().GraphicsDevice.SetRenderTarget(null); }
public override void Draw(Graphics.Graphics graphics) { var spriteFont = graphics.GetSpriteFontByName("minecraft"); var textSize = spriteFont.MeasureString(Text); var center = textSize / 2; graphics.GetSpriteBatch().DrawString ( spriteFont, Text, PositionSize.ToVector2(), Color.Yellow, (float)DegreesToRadians(-20), center, (float)Scale, Microsoft.Xna.Framework.Graphics.SpriteEffects.None, 1f ); }
private void DrawBackground(Graphics.Graphics graphics) { var texture = graphics.GetTexture2DByName("terrain"); int tx, ty; tx = (int)Math.Ceiling((double)graphics.GetGraphicsDeviceManager().GraphicsDevice.Viewport.Width / 32); ty = (int)Math.Ceiling((double)graphics.GetGraphicsDeviceManager().GraphicsDevice.Viewport.Height / 32); Vector2 textureIndex = new Vector2(13 * Constants.SpriteSize, 7 * Constants.SpriteSize); for (int x = 0; x < tx; x++) for (int y = 0; y < ty; y++) graphics.GetSpriteBatch().Draw(texture, new Vector2(x * Constants.TileSize, y * Constants.TileSize).ToRectangle(), textureIndex.ToRectangle(Constants.SpriteSize), Color.White); }
private void DrawLight(Graphics.Graphics graphics) { graphics.GetGraphicsDeviceManager().GraphicsDevice.SetRenderTarget(Lightpass); graphics.GetSpriteBatch().Begin(blendState: BlendState.Additive); graphics.GetGraphicsDeviceManager().GraphicsDevice.Clear(new Color(75, 75, 75, 100)); //ambient light Lights.ForEach(light => { graphics.GetSpriteBatch().Draw(graphics.GetTexture2DByName("circle"), light.rectangle, light.color); }); var point = Minecraft2D.InputHelper.MousePosition.ToPoint(); point.X -= (graphics.GetTexture2DByName("circle").Width / 2); point.Y -= (graphics.GetTexture2DByName("circle").Height / 2); graphics.GetSpriteBatch().Draw(graphics.GetTexture2DByName("circle"), point.ToVector2(), Color.White); graphics.GetSpriteBatch().End(); graphics.GetGraphicsDeviceManager().GraphicsDevice.SetRenderTarget(null); }
private void DrawFullyLit(Graphics.Graphics graphics) { graphics.GetGraphicsDeviceManager().GraphicsDevice.SetRenderTarget(FullyLitWorld); graphics.GetSpriteBatch().Begin(); graphics.GetGraphicsDeviceManager().GraphicsDevice.Clear(Color.CornflowerBlue); graphics.GetSpriteBatch().Draw(graphics.GetTexture2DByName("trivium"), new Rectangle(0, 0, 800, 350), Color.White); graphics.GetSpriteBatch().End(); graphics.GetGraphicsDeviceManager().GraphicsDevice.SetRenderTarget(null); }
public override void Draw(Graphics.Graphics graphics) { DrawFullyLit(graphics); DrawLight(graphics); graphics.GetGraphicsDeviceManager().GraphicsDevice.Clear(Color.White); //graphics.GetSpriteBatch().Begin(SpriteSortMode.Deferred, Multiply, null, null, null, null, null); graphics.GetSpriteBatch().Begin(blendState: Multiply, sortMode: SpriteSortMode.Immediate); graphics.GetSpriteBatch().Draw(FullyLitWorld, graphics.ScreenRectangle(), Color.White); if(RenderLight) graphics.GetSpriteBatch().Draw(Lightpass, graphics.ScreenRectangle(), Color.White); graphics.GetSpriteBatch().End(); }