public void Render(IScreenBuffer screen, PlayerInfo player) { screen.Clear(); // The screen has an origin in the top left. Positive Y is DOWN // Maps have an origin in the bottom left. Positive Y is UP _camera.ScreenBounds = screen.Dimensions; _camera.Center = player.Position; _camera.RotationInRadians = _settings.RotateMode ? player.Angle - MathHelper.PiOver2 : 0; // Transform all vertices for (int v = 0; v < _map.Vertices.Length; v++) { _verticesInScreenCoords[v] = ToScreenCoords(_map.Vertices[v]); } Point ToScreenCoords(Vector2 worldCoordinate) { return(_camera.WorldToScreen(worldCoordinate).ToPoint()); } void DrawLineFromVertices(int v1, int v2, Color c) => DrawLineFromScreenCoordinates(_verticesInScreenCoords[v1], _verticesInScreenCoords[v2], c); void DrawLineFromWorldCoordinates(Vector2 wc1, Vector2 wc2, Color c) { var sc1 = ToScreenCoords(wc1); var sc2 = ToScreenCoords(wc2); DrawLineFromScreenCoordinates(sc1, sc2, c); } void DrawLineFromScreenCoordinates(Point sc1, Point sc2, Color c) { var result = LineClipping.ClipToScreen(screen, sc1, sc2); if (result.shouldDraw) { _drawLine(screen, result.p0, result.p1, c); } } void DrawCircle(Vector2 center, float radiusInWorldCoordinates, Color c) { screen.PlotCircle(_camera.WorldToScreen(center).ToPoint(), (int)(radiusInWorldCoordinates * _camera.TotalZoom), c); } void DrawBox(Vector2 center, float halfWidth, Color c) { var topLeft = center + new Vector2(-halfWidth, halfWidth); var topRight = center + new Vector2(halfWidth, halfWidth); var bottomLeft = center + new Vector2(-halfWidth, -halfWidth); var bottomRight = center + new Vector2(halfWidth, -halfWidth); DrawLineFromWorldCoordinates(topLeft, topRight, c); DrawLineFromWorldCoordinates(topRight, bottomRight, c); DrawLineFromWorldCoordinates(bottomRight, bottomLeft, c); DrawLineFromWorldCoordinates(bottomLeft, topLeft, c); } void DrawVertex(Vector2 wc, Color c) => DrawBox(wc, VertexHalfWidth, c); foreach (var lineDef in _map.Map.LineDefs) { ref Vector2 vertex1 = ref _map.Vertices[lineDef.V1]; ref Vector2 vertex2 = ref _map.Vertices[lineDef.V2];