Re: Mr. BallGuy 2!!!! ***V0.1.1 ALPHA***
Posted: Sun Jun 23, 2013 4:20 pm
For me, the game starts to become really slow when the score is higher than the highscore.
I wondered why, so I looked into the source code.
You are doing filesystem input/output every frame, which is not a good thing.
It can be a major bottleneck, especially if the user doesn't have a really fast disk.
Ideally, you shouldn't do any filesystem operations in love.update(). It would be enough to update the high score when the player dies, for example.
I wondered why, so I looked into the source code.
You are doing filesystem input/output every frame, which is not a good thing.
Code: Select all
function love.update(dt)
...
if player.score > tonumber(player.highscore) then
player.highscore = player.score
lf.write("highscores.lua", "player.highscore\n=\n" .. player.score)
lf.read("highscores.lua")
end
lf.read("highscores.lua")
lf.read("coin.lua")
...
Ideally, you shouldn't do any filesystem operations in love.update(). It would be enough to update the high score when the player dies, for example.