Sawyer
Member
Hello everyone,
I did a teleport range in my little project.
If mouse_x and mouse_y is > max_range so i stop to display the cursor, and i draw a sprite at the coordinate i want using lengthdir.
My problem is that i also want to clamp mouse_x and mouse_y in the max_range to avoid my mouse going too far from x_desti y_desti.
The problem is that mouse_x and y are read only variable.
Can you help me?
I did a teleport range in my little project.
If mouse_x and mouse_y is > max_range so i stop to display the cursor, and i draw a sprite at the coordinate i want using lengthdir.
GML:
var x_desti = mouse_x
var y_desti = mouse_y
direction = point_direction(x, y, mouse_x, mouse_y);
if distance_to_point(x_desti, y_desti) > max_range
{
x_desti = obj_player.x + lengthdir_x(max_range, direction)
y_desti = obj_player.y + lengthdir_y(max_range, direction)
}
if distance_to_point(mouse_x, mouse_y) < max_range
{
cursor_sprite = spr_crosshair
}
else
{
cursor_sprite = noone
draw_sprite(spr_crosshair, 0 , x_desti, y_desti)
}
The problem is that mouse_x and y are read only variable.
Can you help me?