Skip to content

Commit 731d3fb

Browse files
authored
Improve Laser Logic
Lasers would sometimes misorder objects
1 parent 7a0ac7b commit 731d3fb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

laser.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ function laser:update(dt)
129129
local biggesti
130130

131131
for j = 1, #rectcol, 2 do
132-
if objects[rectcol[j]][rectcol[j+1]].x > biggestx then
133-
biggestx = objects[rectcol[j]][rectcol[j+1]].x
132+
if objects[rectcol[j]][rectcol[j+1]].x + objects[rectcol[j]][rectcol[j+1]].width > biggestx then
133+
biggestx = objects[rectcol[j]][rectcol[j+1]].x + objects[rectcol[j]][rectcol[j+1]].width
134134
biggesti = j
135135
end
136136
end
@@ -141,8 +141,8 @@ function laser:update(dt)
141141
local biggesti
142142

143143
for j = 1, #rectcol, 2 do
144-
if objects[rectcol[j]][rectcol[j+1]].y > biggesty then
145-
biggesty = objects[rectcol[j]][rectcol[j+1]].y
144+
if objects[rectcol[j]][rectcol[j+1]].y + objects[rectcol[j]][rectcol[j+1]].height > biggesty then
145+
biggesty = objects[rectcol[j]][rectcol[j+1]].y + objects[rectcol[j]][rectcol[j+1]].height
146146
biggesti = j
147147
end
148148
end

0 commit comments

Comments
 (0)