Page 1 of 1

Need Help! (Images + Filesystem)

Posted: Sat Mar 06, 2010 3:17 pm
by Robotboy655
Hello!

I have some questions about drawing images and filesystem.

I have trouble with drawing resized 1600x1200 image (Making background for a game), when i drawing the image via this code:

Code: Select all

local bg = love.graphics.newImage("background01.jpg")
love.graphics.draw(bg,0,0,0,love.graphics.getWidth() / bg:getWidth(),love.graphics.getHeight() / bg:getHeight(),0,0)
the game have less then 10 fps. Any ideas how to fix that?

About the filesystem: I already know how to write and read files, but i need somehow write files into the root folder of a .love/.exe (or even into the .love/.exe file) and i have no idea how to do that. Can anyone help me?

Re: Need Help! (Images + Filesystem)

Posted: Sat Mar 06, 2010 3:24 pm
by kalle2990
Don't load the image in love.draw, that will cause the game to slow down quite much. Do it in love.load instead :)

Code: Select all

function love.load()
   bg = love.graphics.newImage("background01.jpg")
end

function love.draw()
   love.graphics.draw(bg,0,0,0,love.graphics.getWidth() / bg:getWidth(),love.graphics.getHeight() / bg:getHeight(),0,0)
end
Robotboy655 wrote:About the filesystem: I already know how to write and read files, but i need somehow write files into the root folder of a .love/.exe (or even into the .love/.exe file) and i have no idea how to do that. Can anyone help me?
That is not possible, and will never be (I think)... :? If you can explain what you're using it for I should be able to find another way of doing it though ^^

Re: Need Help! (Images + Filesystem)

Posted: Sat Mar 06, 2010 3:33 pm
by Robotboy655
Thank you! No lag now :D
About the filesystem: I want to create a config file, where i will save the screen resolution, and other stuff, to carry it over sessions.

Re: Need Help! (Images + Filesystem)

Posted: Sat Mar 06, 2010 3:56 pm
by Robin
Robotboy655 wrote:Thank you! No lag now :D
About the filesystem: I want to create a config file, where i will save the screen resolution, and other stuff, to carry it over sessions.
Saving to conf.lua should work, I think. If not, just say t.screen = false in conf.lua, and do a setMode() with values loaded from your config file in love.load().

Re: Need Help! (Images + Filesystem)

Posted: Sun Mar 07, 2010 2:41 am
by Jasoco
Löve is sandboxed. i.e. it has access to the filesystem in a limited fashion so as to not allow destruction of important system files. By giving each game its own subfolder to play around in, it can create and destroy files on a whim without causing problems. Sadly since the sandbox is saved per user, you will not be able to save sessions across users. i.e. save files that all users can access. The other users will have to create the files again for each one when they run the game.