onceadrog / lagrange

A space game
MIT License
1 stars 1 forks source link

Zooming scripts have bugs #2

Open onceadrog opened 6 years ago

onceadrog commented 6 years ago

Zooms out too far with weird results (exceeds room scope). Also would be nice to zoom in on mouse location instead (easy fix)

cij11 commented 6 years ago

This will cause problems:

// Scale the view view_wview[view] = amount; view_hview[view] = amount;

Rounding errors will accumulate independently in the horizontal and vertical view, causing distortions. You could use linear interpolation to do this. Use an aspect ratio to keep the horizontal and vertical components in the same proportion.

zoomPercentage = 0; if (zoomPercentage < 0) zoomPercentage = 0; if(zoomPercentage > 1)zoomPercentage = 1;

view_wview[view] = zoomPercentage wviewMax + (1 - zoomPercentage) wviewMin;
view_hview[view] = view_wview[view] * aspectRatio;

onceadrog commented 6 years ago

Nice. I want to scroll window based on mouse close to edge as well (after a pause to allow moving across the edge of the map). Will look at tomorrow along with room size for Earth/Moon system. Probably go with a square screen, and stick a dashboard on the side (useful for debugs in the interim).