Being a beginner, I've had to do a lot of hard thinking and I got somewhere nice. But now I've hit a wall that I have absolutely no idea how to solve.
... The blocks refuse to merge...
I'm guessing it's gonna take somebody with a good amount of experience with HC to figure this one out.
Anyways, here's my code. The stuff from the beginning is taken from a tile map
Code: Select all
for y=1, map_h do
for x=1, map_w do
if map[y+map_y][x+map_x] == 1 then -- if it's a wall tile
px = (x*tile_w)+map_offset_x
py = (y*tile_h)+map_offset_y
table.insert(wallTilesP1, polygon(px,py,px + 34,py,px,py + 34, px + 34, py, px + 34, py +34, px, py + 34)) -- Now we have all our block polygons, let us combine the colliding ones together
end
end
end
for i = 1, #wallTilesP1, 1 do
for z = 1, #wallTilesP1, 1 do
if wallTilesP1[i] ~= wallTilesP1[z] then
debug1 = "Performing colliding shape test"
if wallTilesP1[i]:mergedWith(wallTilesP1[z]) ~= nil then
debug1 = "WE HAS COLLIDING SHAPES!!"
table.insert(wallTilesP1, wallTilesP1[i]:mergedWith(wallTilesP1[z]))
table.remove(wallTilesP1,z)
table.remove(wallTilesP1,i)
end
end
end
end