public void Draw(Level level, SpriteBatch spriteBatch) { if (!level.EntityWorld.TryGetEntity(_entityID, out Entity? entity)) { return; } if (!level.PhysicsWorld.TryGetBody(entity.BodyID, out Body? body)) { return; } _sprite.Rotation = entity.Rotation; _animation?.Apply(_sprite, _animationTimer); _sprite.Draw(spriteBatch, Vector2.Round(GraphicsConstants.PhysicsToView(body.Position + body.Bounds.Center))); }
public void Draw(Level level, Camera2D camera) { _waterOutlineAnimation.Apply(_waterOutlineSprite, _animationTimer); _spriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: camera.GetTransformMatrix()); int startX = (int)Math.Floor(camera.Position.X / _waterSize); int endX = (int)Math.Floor((camera.Position.X + _spriteBatch.GraphicsDevice.Viewport.Width) / _waterSize); int top = level.TileMap.Height * GraphicsConstants.TileSize - (int)Math.Round(GraphicsConstants.PhysicsToView(level.WaterLevel)); for (int x = startX; x <= endX; x++) { _waterOutlineSprite.Draw(_spriteBatch, new Vector2(x * _waterSize, top - _waterSize / 2f)); } _spriteBatch.End(); }
private void PreDraw(DrawInfo drawInfo) { ApplyProperties(); doAnimation = false; if (animation != null) { if (animation.LifeTime.IsExpired) { animation = null; } else { doAnimation = true; animation.Apply(this, drawInfo); animation.LifeTime.Update(drawInfo.Dt, drawInfo.DrawCount); } } }