What I want to know is how to check which tiles are in the collision map and then make a rectangle shape (hardoncollider) at its position
Like this
Red: Bounding Box
Green: Tiles
At first:(Bad art explanation! lol)
After Checking which tiles are collidable:
level.lua
Code: Select all
level = {}
function level.load()
-- Grab window size
windowWith = love.graphics.getWidth()
windowHeight = love.graphics.getHeight()
-- Load a map exported to Lua from Tiled
map = sti.new("maps/forest1")
Col = map:getCollisionMap("Collidable")
print(Col)
print(Col.properties)
print('\n')
print("Map.width = " .. map.width)
print('\n')
print("Map.orientation = " .. map.orientation)
print('\n')
print("Map.tileheight = " .. map.tileheight)
print('\n')
print("Map.height = " .. map.height)
print('\n')
print("Map.tilewidth = " .. map.tilewidth)
end
function level.update(dt)
map:update(dt)
end
function level.draw()
local tx = -0
local ty = -7
local w = windowWith
local h = windowHeight
-- Move the top-left-most x/y position by tx/ty, respectively
love.graphics.translate(tx, ty)
-- Draw only the tiles on screen
map:setDrawRange(tx, ty, w, h)
map:draw()
--map:drawCollisionMap(Collision)
end
EDIT: Added .love I dont know if it will help but whatever