ForNeVeR / O21

FOSS remake of U95, an old submarine arcade game from 1995.
MIT License
19 stars 9 forks source link

Refactor the camera-related code #147

Closed ForNeVeR closed 4 months ago

ForNeVeR commented 11 months ago

For now, we have a lot of copy-pasted fragments like this:

            let struct (windowWidth, windowHeight) = window.WindowSizePx
            let struct (renderTargetWidth, renderTargetHeight) = window.RenderTargetSize

            let cameraTargetX = ((windowWidth |> float32) - (renderTargetWidth |> float32) * camera.zoom) / -2f / camera.zoom
            let cameraTargetY = ((windowHeight |> float32) - (renderTargetHeight |> float32) * camera.zoom) / -2f / camera.zoom

            camera.target <- Vector2(cameraTargetX, cameraTargetY)
            camera.zoom <- min ((windowHeight |> float32) / (renderTargetHeight |> float32))
                                    ((windowWidth |> float32) / (renderTargetWidth |> float32))

We should extract that to a reusable function.

ForNeVeR commented 4 months ago

Closed by #151.