Hi all, I've been having a blast using love2D to learn LUA. The project I am currently working on is a SHMUP and I plan on putting it in an arcade cabinet. Right now though, i'm still learning the ins and outs of lua, and i'm having problems with love.graphics.getModes().
Could somebody explain to me how to use this function?
Thanks :ugeek:
An example for love.graphics.getModes() ?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: An example for love.graphics.getModes() ?
love.graphics.getModes returns a table which is something like {{width=..., height=...}, {width=..., height=...}, ...}.
I've attached a small program to show the modes:
I've attached a small program to show the modes:
Code: Select all
function load()
modes = love.graphics.getModes()
local font = love.graphics.newFont(love.default_font)
love.graphics.setFont(font)
end
function draw()
-- modes is {{width=..., height=...}, {width=..., height=...}, ...}
for i, mode in ipairs(modes) do
local desc = string.format("mode %d: %dx%d", i, mode.width, mode.height)
love.graphics.draw(desc, 10, i * 20)
end
end
- Attachments
-
- getmodes.love
- (333 Bytes) Downloaded 295 times
Re: An example for love.graphics.getModes() ?
Thank you very much! That looked somewhat like my code that I originally had.
Looks like I need to work on my fundamentals. Does anybody know any good lua tutorials?
I've had a lot of experience with python in the past, as well as c and c++, Lua seems to take a somewhat different approach for things like collections and loops.
Code: Select all
function load()
x = love.graphics.getModes()
end
function update(dt)
end
function draw()
local i = 0
for w,h in pairs(x) do
local drawStr = w.." "..h
love.graphics.draw(drawStr,0,i*20)
i = i +1
end
end
I've had a lot of experience with python in the past, as well as c and c++, Lua seems to take a somewhat different approach for things like collections and loops.
Re: An example for love.graphics.getModes() ?
I've updated the documentation to include this example. I hope that's okay, surtic.
Re: An example for love.graphics.getModes() ?
Of course that's ok.
I'd be happy to write more examples and tutorials - where can I send them to? (Also, is there a concise list of wanted tutorials, something a bit shorter than the endless thread?)
For Lua tutorials, the first point of reference is the Lua website (http://www.lua.org) and the Lua wiki (http://lua-users.org/wiki/) which contains a few tutorials (http://lua-users.org/wiki/TutorialDirectory).
I'd be happy to write more examples and tutorials - where can I send them to? (Also, is there a concise list of wanted tutorials, something a bit shorter than the endless thread?)
For Lua tutorials, the first point of reference is the Lua website (http://www.lua.org) and the Lua wiki (http://lua-users.org/wiki/) which contains a few tutorials (http://lua-users.org/wiki/TutorialDirectory).
Re: An example for love.graphics.getModes() ?
@surtic:
Hmm, there aren't that many tutorial requests these days. I think we better stick to code examples in the documentation for now.
Hmm, there aren't that many tutorial requests these days. I think we better stick to code examples in the documentation for now.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest