Mazey
Member
Hello
In the project I'm working on, I move my mouse over blocks, when my mouse is on a block the block's color changes, this is working fine. My issue is that the mouse 'skips' blocks when you move the mouse too fast, which shouldn't be possible, so I'm trying to interpolate the mouse movement.
Here is the code I'm using right now, but the game freezes as soon as the game starts (because of the while loop):
Am I missing something?
In the project I'm working on, I move my mouse over blocks, when my mouse is on a block the block's color changes, this is working fine. My issue is that the mouse 'skips' blocks when you move the mouse too fast, which shouldn't be possible, so I'm trying to interpolate the mouse movement.
Here is the code I'm using right now, but the game freezes as soon as the game starts (because of the while loop):
Code:
//create event obj_mouse
x = mouse_x;
y = mouse_y;
_x = x;
_y = y;
//step event obj_mouse
x = mouse_x;
y = mouse_y;
if (point_distance(_x,_y,mouse_x,mouse_y) > sprite_get_width(spr_block))
{
x = _x;
y = _y;
while (x != mouse_x && y != mouse_y)
{
x += lengthdir_x(1,point_direction(x,y,mouse_x,mouse_y));
y += lengthdir_y(1,point_direction(x,y,mouse_x,mouse_y));
}
}
_x = x;
_y = y;