Use logarithmic zoom scaling in 2d camera zoom examples
This commit is contained in:
parent
cd9206956c
commit
8b84c999d2
2 changed files with 10 additions and 8 deletions
|
@ -14,6 +14,7 @@
|
|||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
#include <math.h>
|
||||
|
||||
#define MAX_BUILDINGS 100
|
||||
|
||||
|
@ -81,7 +82,8 @@ int main(void)
|
|||
else if (camera.rotation < -40) camera.rotation = -40;
|
||||
|
||||
// Camera zoom controls
|
||||
camera.zoom += ((float)GetMouseWheelMove()*0.05f);
|
||||
// Uses log scaling to provide consistent zoom speed
|
||||
camera.zoom = expf(logf(camera.zoom) + ((float)GetMouseWheelMove()*0.05f));
|
||||
|
||||
if (camera.zoom > 3.0f) camera.zoom = 3.0f;
|
||||
else if (camera.zoom < 0.1f) camera.zoom = 0.1f;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue