[Solved] love.draw and RAM overuse
Posted: Wed Jan 11, 2012 8:27 pm
Hello! I'm new to this community, LÖVE, and Lua and am only somewhat acquainted with programming. I've read through Kikito's Love-Tile-Tutorial on GitHub as well as the Hamster Ball tutorial and use most of the code demonstrated there in the program I'm building now. I've also been through the 78 pages of this Support and Development forum reading anything with a title that might provide some clues as to why I'm experiencing the problem I'm having but didn't find anything directly related. (I did find tons of other useful things, though! )
What the program does:
Draws a tilemap to the screen using Kikito's string method
Draws a controllable character (Up, Down, Left, Right) to the screen from another tileset
The Problem: The program runs fully functioning for about 10 seconds, though with each passing second it uses 8% more RAM until the program crashes.
After some troubleshooting I believe I've pinpointed the issue to my function for drawing the character -
This function is stored in a separate piece of code (Player-Functions.lua) and is called in Main.Lua at the love.draw function:
When I delete the drawPlayer() function and just allow the map to be drawn, the program runs as expected, using a normal amount of RAM.
My first intuition was that redrawing the character every frame was using exponential amounts of RAM, if it saves a new character rather than overwrite the current one. However, my intuition isn't programming minded yet, so after trying some different things and failing I have come to you!
What the program does:
Draws a tilemap to the screen using Kikito's string method
Draws a controllable character (Up, Down, Left, Right) to the screen from another tileset
The Problem: The program runs fully functioning for about 10 seconds, though with each passing second it uses 8% more RAM until the program crashes.
After some troubleshooting I believe I've pinpointed the issue to my function for drawing the character -
Code: Select all
function drawPlayer()
playerImage = love.graphics.newImage('/tilesets/characters.png')
fancyGhoul = love.graphics.newQuad(0, 0, 64, 64, 640, 640)
love.graphics.drawq(playerImage, fancyGhoul, player.act_x, player.act_y)
end
Code: Select all
function love.draw()
drawMap()
drawPlayer()
end
My first intuition was that redrawing the character every frame was using exponential amounts of RAM, if it saves a new character rather than overwrite the current one. However, my intuition isn't programming minded yet, so after trying some different things and failing I have come to you!