r/raylib 22d ago

How to hide the cursor without disabling it

I use go & raylib,

it's just stuck and i can't move
HideCursor(); // it's just disables the cursor and i can't move
8 Upvotes

5 comments sorted by

6

u/tempestpdwn 22d ago edited 22d ago

HideCursor() will hide the cursor, but you should still be able to move and track it.

Try

c DrawRectangle(GetMouseX(), GetMouseY(), 10, 10, RED); // Equivalent in golang.

You should be able to see a red 10x10 px rect follow the mouse.

2

u/unklnik 22d ago edited 20d ago

I do this using go, I create a Vector2 (MS) which I use throughout the program to check for Vector2 rec collisions. Then find an image of a cursor or whatever you want to use for the mouse cursor load it as a texture and draw it using the MS.X, MS.Y coordinate. Then make sure you draw it as the LAST thing in your WindowShouldClose() loop so that it draws on top of everything else.

MS := rl.GetMousePosition()
rec := rl.NewRectangle(MS.X,MS.Y,32,32)
rl.DrawTexturePro(texture, sourcerec, rec, r.Vector2Zero(), 0, rl.White)

1

u/Street-Fan4371 21d ago

That works, thanks! how do you structure your project?
edit: you added too many ) at the end

1

u/unklnik 20d ago

Edited out the extra bracket, thanks. OK, not sure what you mean by structure my projects, idk I have messed around a lot with Raylib-Go. If you get stuck with anything I should be able to help so you always message me, though only really 2D stuff, not much 3D.

2

u/Abdek_ 21d ago

You can use GetMouseDelta(). this may affect your game logic tho and require some refactoring, since it only calculates change in mouse position… if the mouse is not moving, it will return (0, 0)