Each step, set a mouse_xprevious and mouse_yprevious. You can then get the direction using [snip=EDL]point_direction(mouse_xprevious, mouse_yprevious, mouse_x, mouse_y)[/snip], and likewise, the speed using [snip=EDL]point_distance(mouse_xprevious, mouse_yprevious, mouse_x, mouse_y)[/snip].
To also test if the mouse has passed through your object, use this:
if (collision_line(mouse_xprevious, mouse_yprevious, mouse_x, mouse_y, obj_myobject, true, true)) { double dir, spd; dir = point_direction(mouse_xprevious, mouse_yprevious, mouse_x, mouse_y); spd = point_distance(mouse_xprevious, mouse_yprevious, mouse_x, mouse_y); // ... } mouse_xprevious = mouse_x; mouse_yprevious = mouse_y;
|