J
jgaryedyen
Guest
Title is not 100% accurate but I'm not sure what to call my problem. The distance_to_object is working but it's not working for what I want it to do.
I'm trying to create a basic tower defense but I'm having some problems with the distance_to_object function. It seems to have boundaries in a square shape however I want to use it for the typical circular tower radius.
This is the step event:
if placed = false {
x = mouse_x
y = mouse_y
} else if placed = true {
if instance_exists(target) == true && distance_to_object(target) < range {
coolDown -= 1;
if coolDown == 0 {
instance_create_depth(x, y, 0, proj);
coolDown = fireRate;
}
}
}
And this is the draw event for the tower:
draw_self();
draw_set_color(c_dkgray);
draw_set_alpha(0.5);
if selected = true {
draw_circle(x, y, range + 32, false);
}
draw_set_alpha(1);
Any other advice such as how to improve my code in general is also appreciated.
(This question might have already been answered but I don't know what to search to find it)
I'm trying to create a basic tower defense but I'm having some problems with the distance_to_object function. It seems to have boundaries in a square shape however I want to use it for the typical circular tower radius.
This is the step event:
if placed = false {
x = mouse_x
y = mouse_y
} else if placed = true {
if instance_exists(target) == true && distance_to_object(target) < range {
coolDown -= 1;
if coolDown == 0 {
instance_create_depth(x, y, 0, proj);
coolDown = fireRate;
}
}
}
And this is the draw event for the tower:
draw_self();
draw_set_color(c_dkgray);
draw_set_alpha(0.5);
if selected = true {
draw_circle(x, y, range + 32, false);
}
draw_set_alpha(1);
Any other advice such as how to improve my code in general is also appreciated.
(This question might have already been answered but I don't know what to search to find it)