public override void Render(Game0 game, double interpolation) { base.Render(game, interpolation); var view = game.Camera.InterpolatedView(interpolation); if (game.Player.Alive || Fade) { // parallax scrolling var parallax = view.Min / (game.CurrentLevel.Size - view.Size); var lights = game.Entities.Where(e => e is Light).Select(e => e as Light).ToArray(); var obstacles = game.Entities.Where(e => (e as Obstacle) != null).Select(e => (e as Obstacle).BoundingBox + e.Position) .Concat(new[] { game.Player.BoundingBox + game.Player.InterpolatedPosition(interpolation) }) .ToArray(); // render all layers, back to front foreach (var layer in game.CurrentLevel.Layers) { // main layer if (layer.Depth == 0) { // background layer Rendering.Render(view, layer, lights, obstacles); // entities foreach (var entity in game.Entities) { (entity as IRender)?.Render(view, interpolation); } } else { // background / foreground layers (with possible parallax scrolling) Renderer.Instance.RenderLayer(!layer.Parallax ? view : (new AABB(Vector2f.Zero, view.Size) + (layer.Size - view.Size) * parallax), layer); } } // debug DebugData.Render(view, interpolation, game.Entities.ToArray()); if (Settings.Instance.GetDebug(DebugSetting.DrawCamera)) { (game.Camera as IRender)?.Render(view, interpolation); } if (Fade) { Renderer.Instance.RenderRectangleOverlay(view, new AABB(Vector2f.Zero, view.Size), new Color4b(0, 0, 0, (byte)FadeFrame)); } } // gameplay gui, always on top Gui.Instance.Render(view, interpolation); }