Lua Syntax and Drawing a Canvas (Solved)

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
NotAUsername
Prole
Posts: 3
Joined: Sat Dec 06, 2014 4:22 am

Lua Syntax and Drawing a Canvas (Solved)

Post by NotAUsername »

I'm kinda' new to both lua and love, so I don't completely know how lua syntax, or the love API, work in every situation.

I'm trying to have everything be drawn to a canvas, then the canvas drawn to the window and stretched to fit it. To do this, I draw the canvas with a scaling factor of the window's dimensions divided by the canvas' dimensions. No matter what I do, my code produces errors.

Here's the line I'm having problems with:

Code: Select all

love.graphics.draw(mainCanvas, 0, 0, 0, love.window.getWidth/mainCanvas:getWidth, love.window.getHeight/mainCanvas:getHeight)
This produces "function arguments expected near ',' " (Keep in mind, this is all one line in the actual code)

First of all, what does this mean? Can I use functions inside other functions? If I can, am I doing it right?
Even if I assign the values of the functions in question to variables first, then use the variables in the draw function, it still produces errors.
Last edited by NotAUsername on Sat Dec 06, 2014 5:07 pm, edited 1 time in total.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Lua Syntax and Drawing a Canvas

Post by Jasoco »

Well, first off you forgot the parenthesis in all cases of getHeight and getWidth.

If you just try to call love.graphics.getWidth, it's not going to work because it's not a variable. It's a function. In order to get it to return the value you want you need to call it like a function. getWidth(). Same goes for everything that's a function.
NotAUsername
Prole
Posts: 3
Joined: Sat Dec 06, 2014 4:22 am

Re: Lua Syntax and Drawing a Canvas

Post by NotAUsername »

I fixed the parentheses problem, but I got the same result. Same error and everything.

Never mind, I fixed it!
Last edited by NotAUsername on Sat Dec 06, 2014 5:07 pm, edited 1 time in total.
User avatar
Doctory
Party member
Posts: 441
Joined: Fri Dec 27, 2013 4:53 pm

Re: Lua Syntax and Drawing a Canvas

Post by Doctory »

can't you just make the canvas size the same as the window size and then change the size if the window is resized?
NotAUsername
Prole
Posts: 3
Joined: Sat Dec 06, 2014 4:22 am

Re: Lua Syntax and Drawing a Canvas

Post by NotAUsername »

I don't think that'll work because then you have to resize everything as it's drawn to the canvas to get the same effect, and at that point you might as well just draw straight to the window.
User avatar
DaedalusYoung
Party member
Posts: 407
Joined: Sun Jul 14, 2013 8:04 pm

Re: Lua Syntax and Drawing a Canvas (Solved)

Post by DaedalusYoung »

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 89 guests