-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmaller_rectangles.lua
More file actions
32 lines (30 loc) · 1.13 KB
/
smaller_rectangles.lua
File metadata and controls
32 lines (30 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
-- from: https://love2d.org/forums/viewtopic.php?p=179044#p179044
for a = 1, #boxSizeList do
local bw, bh = boxSizeList[a][1], boxSizeList[a][2]
local count = bw * bh
for x = 0, #tempColMap-bw+1 do
for y = 0, #tempColMap[1]-bh+1 do
local _count = 0
for bx = x, x + (bw-1) do
for by = y, y + (bh-1) do
if not markedGrid[bx][by] then
if tempColMap[bx][by] == currentTileType then
_count = _count + 1
end
end
end
end
if _count == count then
local n = "solidWall_" .. x+1 .. "_" .. y+1
local wallType = currentTileType
-- Add the newly created collision box to a table that will later be used to generate the Bump collision blocks
self.level.boxList[n] = { x = x * TILESIZE, y = y * TILESIZE, w = bw * TILESIZE, h = bh * TILESIZE, id = n, solid = true }
for bx = x, x + (bw-1) do
for by = y, y + (bh-1) do
markedGrid[bx][by] = true
end
end
end
end
end
end