Issue drawing a simple grid
Posted: Sun Dec 24, 2017 2:10 am
Hi everyone!
This is a pretty simple question, basically I just started learning about Love2d and as a "Hello World" project I decided to make pretty simple sprite editor.
This sprite editor is a 32x32 grid where each cell has 32 pixels of height and 32 pixels of width. You have a red cursor and the selected color is hardcoded (red). If you press the space button it should draw the color in the grid.
Everything works fine! The only issue is that is too slow. I mean, is a pretty simple and straightforward test, shouldn't be this slow.
Here's a video of the compiled project:
I'm attaching the source code.
My question is why is this running so slow? I'm suspecting that is because I'm re-drawing the entire grid in the love.draw() hook. But if I don't do that the "dirty" positions where the cursor has been browsing will keep the color of the cursor. And tracking the cursor movements to clean it up later sounds like too much rocket science for this very simple test.
Thanks in advance for any tip or advice!
This is a pretty simple question, basically I just started learning about Love2d and as a "Hello World" project I decided to make pretty simple sprite editor.
This sprite editor is a 32x32 grid where each cell has 32 pixels of height and 32 pixels of width. You have a red cursor and the selected color is hardcoded (red). If you press the space button it should draw the color in the grid.
Everything works fine! The only issue is that is too slow. I mean, is a pretty simple and straightforward test, shouldn't be this slow.
Here's a video of the compiled project:
I'm attaching the source code.
My question is why is this running so slow? I'm suspecting that is because I'm re-drawing the entire grid in the love.draw() hook. But if I don't do that the "dirty" positions where the cursor has been browsing will keep the color of the cursor. And tracking the cursor movements to clean it up later sounds like too much rocket science for this very simple test.
Thanks in advance for any tip or advice!