A Few Questions on Love and Lua
Posted: Tue Jan 17, 2017 4:40 am
Hi all, new here, though I've lurked and been doing some work with Love and Lua for the past few months. I've stumbled upon a few questions over this time, with limited success searching for answers.
Love Question (On image rendering and coordinate systems):
In my game, I'm using a coordinate system that goes from (0,0) to (32, 18) rather than to the screen size. However, when I draw an image, it is drawn so a single pixel takes up (1, 1) units of the screen.
So, when I'm drawing a 32x32 quad, at 1x scale it covers more than the entire screen, so I have to scale it by 1/32. Is there a way to set the default scaling to 1/32 size (so that a 32x32 image at default scale will draw to a 1x1 scale in the coordinate system?). I don't think this is critically important, but it sure would help readability and clarity if I wasn't constantly scaling things by their inverse, haha.
I haven't worked with the Love SpriteBatch yet though I'm planning on implementing it later, so apologies if this works different than the "draw" call and is related to an answer.
Lua/Love Question (On debugging/performance testing and analysis):
Are there any generally useful debugging/analysis programs for Love/Lua?
Lua Question (On [Lua/LuaJIT/FFI C binding]/Performance):
In an algorithm, is it bad practice/slow to use tables rather than a basic data type? And above this, for critical/heavy algorithms, is it even faster to use C through FFI rather than Lua? Does this complicate the packaging process or change which hardware it can run on? I looked on the LuaJIT FFI section and it says it's faster, more lightweight, and (should?) run on any hardware LuaJIT runs on, but if someone has real experience with it a second opinion would be nice.
If it changes any of the answers, I'm currently running the most recent Love, on Linux Lubuntu 16.10. Thanks a lot in advance, and I'm excited to join this community!
Love Question (On image rendering and coordinate systems):
In my game, I'm using a coordinate system that goes from (0,0) to (32, 18) rather than to the screen size. However, when I draw an image, it is drawn so a single pixel takes up (1, 1) units of the screen.
So, when I'm drawing a 32x32 quad, at 1x scale it covers more than the entire screen, so I have to scale it by 1/32. Is there a way to set the default scaling to 1/32 size (so that a 32x32 image at default scale will draw to a 1x1 scale in the coordinate system?). I don't think this is critically important, but it sure would help readability and clarity if I wasn't constantly scaling things by their inverse, haha.
I haven't worked with the Love SpriteBatch yet though I'm planning on implementing it later, so apologies if this works different than the "draw" call and is related to an answer.
Lua/Love Question (On debugging/performance testing and analysis):
Are there any generally useful debugging/analysis programs for Love/Lua?
- Debugging - perhaps something window based running [along] the Love file, showing a Tree of currently used variables and their values?
- Analysis like something that plots memory usage VS time, records garbage dumps, etc. I've used tools like this that interacted with the Java VM, but I couldn't find anything similar for Lua. Not sure if I was looking in the wrong places, or if they don't exist.
Lua Question (On [Lua/LuaJIT/FFI C binding]/Performance):
In an algorithm, is it bad practice/slow to use tables rather than a basic data type? And above this, for critical/heavy algorithms, is it even faster to use C through FFI rather than Lua? Does this complicate the packaging process or change which hardware it can run on? I looked on the LuaJIT FFI section and it says it's faster, more lightweight, and (should?) run on any hardware LuaJIT runs on, but if someone has real experience with it a second opinion would be nice.
If it changes any of the answers, I'm currently running the most recent Love, on Linux Lubuntu 16.10. Thanks a lot in advance, and I'm excited to join this community!