If you can spare a few dollars, it would help a lot: PayPayl.me/Guard13007
It’s been about a year of subpar income with no benefits, keeping us alive but still in danger, and now that is gone entirely. :D
Miscellaneous Idea Storage
If you can spare a few dollars, it would help a lot: PayPayl.me/Guard13007
It’s been about a year of subpar income with no benefits, keeping us alive but still in danger, and now that is gone entirely. :D
It seems a common misconception that images cannot be loaded from outside of the source code directory, but you can. Love’s love.graphics.newImage function doesn’t accept file paths outside of the source directory, but it’s pretty easy to work around.
Assume the following file structure:
working directory/
src/
main.lua
image.png
And here’s the code that will load that image:
-- images must be opened in binary mode
local file = io.open("image.png", "rb")
local data = file:read("*all")
file:close()
local byte_data = love.data.newByteData(data)
local image = love.graphics.newImage(byte_data)
I see people running into this problem all the time and no one seems to dig deeper. While it’s bad practice for many uses to do this, sometimes it’s necessary. For example, I made a little mapping program that can load maps from drag-and-drop – which always means files outside of the source directory.