(main)~fixed bug with zooming out too far
Stopped presenting the simulation after a while.
This commit is contained in:
19
main.c
19
main.c
@@ -54,6 +54,7 @@ int main(void)
|
||||
camera.zoom = 1.0f;
|
||||
InitWindow(state.window_len, state.window_len, "Abelian sand pile");
|
||||
SetTargetFPS(60);
|
||||
const float zoom = 0.125f;
|
||||
|
||||
while (!WindowShouldClose())
|
||||
{
|
||||
@@ -61,17 +62,23 @@ int main(void)
|
||||
|
||||
if (IsKeyPressed(KEY_UP) || IsKeyDown(KEY_UP))
|
||||
{
|
||||
Vector2 world_pos = GetScreenToWorld2D(GetMousePosition(), camera);
|
||||
camera.offset = GetMousePosition();
|
||||
Vector2 centre = {state.window_len / 2, state.window_len / 2};
|
||||
Vector2 world_pos = GetScreenToWorld2D(centre, camera);
|
||||
camera.offset = centre;
|
||||
camera.target = world_pos;
|
||||
camera.zoom += 0.125f;
|
||||
camera.zoom += zoom;
|
||||
if (camera.zoom < zoom)
|
||||
camera.zoom = zoom;
|
||||
}
|
||||
if (IsKeyPressed(KEY_DOWN) || IsKeyDown(KEY_DOWN))
|
||||
{
|
||||
Vector2 world_pos = GetScreenToWorld2D(GetMousePosition(), camera);
|
||||
camera.offset = GetMousePosition();
|
||||
Vector2 centre = {state.window_len / 2, state.window_len / 2};
|
||||
Vector2 world_pos = GetScreenToWorld2D(centre, camera);
|
||||
camera.offset = centre;
|
||||
camera.target = world_pos;
|
||||
camera.zoom -= 0.125f;
|
||||
camera.zoom -= zoom;
|
||||
if (camera.zoom < zoom)
|
||||
camera.zoom = zoom;
|
||||
}
|
||||
|
||||
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
|
||||
|
||||
Reference in New Issue
Block a user