I'm trying to use a pretty standard map with the Simple Tiled Implementation module for Love2D, but no matter what I try, I can't get it to display anything but a black screen. Here's my current code (keybindings in an effort to see if the map has just been placed offscreen):
local sti = require "sti"
local mapPos = { x = 0, y = 0 }
function love.load()
map = sti("maps/map1.lua")
end
function love.update(dt)
if love.keyboard.isDown("w") or love.keyboard.isDown("up") then
mapPos.y = mapPos.y - 5
end
-- Move player down
if love.keyboard.isDown("s") or love.keyboard.isDown("down") then
mapPos.y = mapPos.y + 5
end
-- Move player left
if love.keyboard.isDown("a") or love.keyboard.isDown("left") then
mapPos.x = mapPos.x - 5
end
-- Move player right
if love.keyboard.isDown("d") or love.keyboard.isDown("right") then
mapPos.x = mapPos.x + 5
end
map:update(dt)
end
function love.draw()
-- Transform world
love.graphics.translate(-mapPos.x, -mapPos.y)
-- Draw world
map:draw()
end
However, even a more basic attempt (copied from the STI tutorial linked from the README on the Github page) doesn't work, again giving a black screen:
-- Include Simple Tiled Implementation into project
local sti = require "sti"
function love.load()
-- Load map file
map = sti("map.lua")
end
function love.update(dt)
-- Update world
map:update(dt)
end
function love.draw()
-- Draw world
map:draw()
end
My directory structure is basically just main.lua
, an assets folder, and a maps folder. The maps folder contains the Tiled tile set and the Tiled .tmx maps and the lua exported maps.
I'm on Mac OSX, using Love2D version 0.10.2.
Am I missing something? Thanks.
main.lua
and put it in the STI repository root, and change the map from "map.lua" to "tests/ortho.lua", and run "love .", it simply works for me. Is there no error message displayed at all? Did you try it with the example map instead of your own? \$\endgroup\$ – Thorbjørn Lindeijer Feb 12 '18 at 8:28