Will this work?
distances = {}
for key,value in ipairs(beacons) do
for i,unit in ipairs(spawned units)
local distance = math.sqrt((unit.x-k.x)^2 + (unit.y-k.y)^2
table.insert(distances,distance)
end
table.sort(distances)
Then pick the last one?
Search found 15 matches
- Tue Oct 24, 2017 2:29 am
- Forum: Support and Development
- Topic: Lighters pause in midpoints
- Replies: 10
- Views: 9228
- Mon Oct 23, 2017 7:51 pm
- Forum: Support and Development
- Topic: Lighters pause in midpoints
- Replies: 10
- Views: 9228
Re: Lighters pause in midpoints
How would I select the closest one?
if distance < k.x,k.y?
if distance < k.x,k.y?
- Sun Oct 22, 2017 3:07 am
- Forum: Support and Development
- Topic: Lighters pause in midpoints
- Replies: 10
- Views: 9228
Re: Lighters pause in midpoints
So if I wanted to do comparison on distance between 2 points from the unit would I do
Code: Select all
unitdist 1 = unit.x - k.x
unit 2 = unit.x - k.x
if unitdist1 < unit2 then
target = unitdist1
else
target = unit2
- Fri Oct 20, 2017 7:33 am
- Forum: Support and Development
- Topic: Lighters pause in midpoints
- Replies: 10
- Views: 9228
Re: Lighters pause in midpoints
for i,v in ipairs(Opposing_Pens) do for k,Beacon in ipairs(Beacons) do if (v.target == nil) then v.target = k elseif (v.target ~= k) then break end So line by line: For each index and value of opposing pens do; for each index and value of beacons do; if the target of opposing pens is non existent; ...
- Thu Oct 19, 2017 7:01 am
- Forum: Support and Development
- Topic: Lighters pause in midpoints
- Replies: 10
- Views: 9228
Re: Lighters pause in midpoints
It actually still does the pause in midpoints. I would like it to go from first beacon placed to second, then third.
Does anyone know how to do that?
Does anyone know how to do that?
- Sun Oct 15, 2017 5:49 am
- Forum: Support and Development
- Topic: Lighters pause in midpoints
- Replies: 10
- Views: 9228
Lighters pause in midpoints
So when you left click; a beacon spawns, they are square and very small When you right click; a spawner appears, spawners are circles The lighters, which are the products of the spawners, will then go to the beacons. However, if you place the beacons in a line like this; The lighters will end up pau...
- Tue Oct 10, 2017 8:11 am
- Forum: Support and Development
- Topic: Why does one of my timers take longer to go down to 0?
- Replies: 1
- Views: 1912
Why does one of my timers take longer to go down to 0?
It could just be my computer, but to me Follow_Timer seems to count down a lot slower than timer: love.graphics.print(Follow_Timer,0,0) love.graphics.print(DirX,0,25) love.graphics.print(DirY,0,50) love.graphics.print(timer,150,0) Both timers are going down by 1*dt, which I think should be the same ...
- Mon Oct 09, 2017 10:03 am
- Forum: Support and Development
- Topic: Deleting enemies if too much
- Replies: 1
- Views: 1903
Deleting enemies if too much
I wish to stop enemies spawning when there are over 5 enemies, keeping the number of enemies at 5 I however have no idea how to do this properly, and as a result the enemies keep spawning and do not stop Might be good to look at: if timer < 1 and MaxPens < 5 then Enemy_Pen_Spawn(randomX,randomY,20,2...
- Mon Oct 02, 2017 8:26 am
- Forum: Support and Development
- Topic: Follower units have a following glitch
- Replies: 1
- Views: 1830
Follower units have a following glitch
What is supposed to happen: The follower is supposed to be following the mouse-controlled player but suffers from glitches. Glitch 1 The follower does not move vertically. That is, it does not move up and down regardless of where the player is. Glitch 2 The follower only follows you to the right if ...
- Sun Sep 24, 2017 2:27 am
- Forum: Support and Development
- Topic: Glitches with the automatic machine gun
- Replies: 4
- Views: 3099
Re: Glitches with the automatic machine gun
Thanks sphyrth!