Limiting cursor speed

Posted By: robertbruce

Limiting cursor speed - 09/20/11 20:39

Hello,

Is there a way to restrict the max speed of moving a cursor across the screen? My mouse code is below. Would appreciate any help.



function init_mouse()
{


mouse_map = arrow_bmp;


mouse_mode = 1;



mouse_spot.x = bmap_width(arrow_bmp)/2; // hot spot in the bmap center
mouse_spot.y = bmap_height(arrow_bmp)/2;

var mouse_limit_x;
var mouse_limit_y;
mouse_limit_x = (screen_size.x - bmap_width(arrow_bmp));
mouse_limit_y = (screen_size.y - bmap_width(arrow_bmp));
while (1)
{
mouse_pos.x = mouse_cursor.x;
mouse_pos.y = mouse_cursor.y;
wait(1);
}

}

thanks,

Rob
Posted By: lostclimate

Re: Limiting cursor speed - 09/20/11 21:58

vec_lerp ? something similar to that should work.
Posted By: Joey

Re: Limiting cursor speed - 09/20/11 22:54

Code:
vec_set(temp, vector(mouse_cursor.x, mouse_cursor.y, 0));
vec_sub(temp, vector(mouse_pos.x, mouse_pos.y, 0));
vec_normalize(temp, minv(42, vec_length(temp)));
mouse_pos.x += temp.x;
mouse_pos.y += temp.y;


Posted By: robertbruce

Re: Limiting cursor speed - 09/21/11 22:04

thanks to you both, will give those a try,

Rob
© 2024 lite-C Forums