Skip to content

Commit a617e1e

Browse files
committed
Update core_2d_camera_mouse_zoom.c
1 parent b47fffb commit a617e1e

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

examples/core/core_2d_camera_mouse_zoom.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ int main ()
4545
else if (IsKeyPressed(KEY_TWO)) zoomMode = 1;
4646

4747
// Translate based on mouse right click
48-
if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT))
48+
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
4949
{
5050
Vector2 delta = GetMouseDelta();
5151
delta = Vector2Scale(delta, -1.0f/camera.zoom);
@@ -76,8 +76,8 @@ int main ()
7676
}
7777
else
7878
{
79-
// Zoom based on mouse left click
80-
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
79+
// Zoom based on mouse right click
80+
if (IsMouseButtonPressed(MOUSE_BUTTON_RIGHT))
8181
{
8282
// Get the world point that is under the mouse
8383
Vector2 mouseWorldPos = GetScreenToWorld2D(GetMousePosition(), camera);
@@ -89,7 +89,7 @@ int main ()
8989
// under the cursor to the screen space point under the cursor at any zoom
9090
camera.target = mouseWorldPos;
9191
}
92-
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
92+
if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT))
9393
{
9494
// Zoom increment
9595
float deltaX = GetMouseDelta().x;
@@ -119,10 +119,16 @@ int main ()
119119
DrawCircle(GetScreenWidth()/2, GetScreenHeight()/2, 50, MAROON);
120120

121121
EndMode2D();
122+
123+
// Draw mouse reference
124+
//Vector2 mousePos = GetWorldToScreen2D(GetMousePosition(), camera)
125+
DrawCircleV(GetMousePosition(), 4, DARKGRAY);
126+
DrawTextEx(GetFontDefault(), TextFormat("[%i, %i]", GetMouseX(), GetMouseY()),
127+
Vector2Add(GetMousePosition(), (Vector2){ -44, -24 }), 20, 2, BLACK);
122128

123129
DrawText("[1][2] Select mouse zoom mode (Wheel or Move)", 20, 20, 20, DARKGRAY);
124-
if (zoomMode == 0) DrawText("Mouse right button drag to move, mouse wheel to zoom", 20, 50, 20, DARKGRAY);
125-
else DrawText("Mouse right button drag to move, mouse press and move to zoom", 20, 50, 20, DARKGRAY);
130+
if (zoomMode == 0) DrawText("Mouse left button drag to move, mouse wheel to zoom", 20, 50, 20, DARKGRAY);
131+
else DrawText("Mouse left button drag to move, mouse press and move to zoom", 20, 50, 20, DARKGRAY);
126132

127133
EndDrawing();
128134
//----------------------------------------------------------------------------------

0 commit comments

Comments
 (0)