GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2011-06-09 23:15:32

Marchal_Mig12
Member
Registered: 2009-05-21
Posts: 72

Better usage of "mouse_x" and "mouse_y"

I always hated built in GM variables and here's an example why. I am drawing a custom sprite as a sprite in my game where I am often zooming in and out which means I have to adjust the cursor's size depending on the view's scale.

Whenever I drew the adjusted cursor sprite, it was ticking on the screen such as if the cursor was buggy. Then I found a little awesome new tricks. Instead of using "mouse_x", I now always use window_mouse_get_x() which does not round the cursor's position to the nearest integer.

Instead, I use this :

mouseX = view_xview+window_mouse_get_x()/window_get_width()*view_wview;

the difference between this and mouse_x is pretty huge since playing a game that is 4x zoomed out on a fullscreen and pretty big monitor, it doesn't tick anymore. When I compared both values, there was decimal differences which was enough to make it very uncomfortable.

I am not sure if I have been clear there thought tongue.

Offline

#2 2011-06-10 06:39:40

xot
Administrator
Registered: 2007-08-18
Posts: 1,201

Re: Better usage of "mouse_x" and "mouse_y"

Great tip! It would not have occurred to me that there would ever be a practical difference in the two ways to read the mouse.


Abusing forum power since 1986.

Offline

Board footer

Powered by FluxBB