--- a/main.lua +++ b/main.lua @@ -1,3 +1,16 @@ +-- Compatibility with LOVE 11 (the game was written for LOVE 0.10): colours are 0..1 instead of 0..255, sources need a +-- type and love.filesystem.isFile is gone. +do + local setColor = love.graphics.setColor + love.graphics.setColor = function (r, g, b, a) + if type(r) == 'table' then r, g, b, a = r[1], r[2], r[3], r[4] end + setColor((r or 255) / 255, (g or 255) / 255, (b or 255) / 255, (a or 255) / 255) + end + local newSource = love.audio.newSource + love.audio.newSource = function (path, kind) return newSource(path, kind or 'static') end + love.filesystem.isFile = function (path) return love.filesystem.getInfo(path, 'file') ~= nil end +end + local sceneHandler = require('src.sceneHandler') local title = require('src.scenes.title') @@ -29,7 +42,7 @@ font:setFilter('nearest', 'nearest') love.graphics.setFont(font) - local music = love.audio.newSource('assets/musak/running_out_of_space.compat.it') + local music = love.audio.newSource('assets/musak/running_out_of_space.compat.it', 'stream') music:setLooping(true) music:setVolume(0.8) music:play() @@ -42,7 +55,6 @@ love.draw = function () GAME.scenes:draw(GAME.screen) - love.graphics.print(love.timer.getFPS()) end love.keypressed = function (key) --- a/src/levelLoader.lua +++ b/src/levelLoader.lua @@ -27,10 +27,9 @@ end return function (levelPath) - local img = love.graphics.newImage(levelPath) - local data = img:getData() - local width = img:getWidth() - local height = img:getHeight() + local data = love.image.newImageData(levelPath) + local width = data:getWidth() + local height = data:getHeight() local levelMap = {} levelMap.map = {} @@ -39,6 +38,7 @@ for i = 0, (width-1) do for j = 0, (height-1) do local r, g, b, a = data:getPixel(i, j) + r, g, b, a = math.floor(r * 255 + 0.5), math.floor(g * 255 + 0.5), math.floor(b * 255 + 0.5), math.floor(a * 255 + 0.5) local pixel = table.concat{r, g, b, a} local t = pixelToTile(pixel, i, j) table.insert(levelMap.map, t)