How exactly does the love functions work? [more questions]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Buddy4point0
Prole
Posts: 35
Joined: Wed Jan 12, 2011 9:29 pm
Location: Virginia

How exactly does the love functions work? [more questions]

Post by Buddy4point0 »

As long as I've been programming in lua, I've always had to do something like this:

Code: Select all

function blah
blah blah blah
end

function blah
blah blah blah
end

while true do
function
function
draw everything to screen
end
Does love automatically loop the draw function?
What other functions does love automatically loop?

Can someone explain basically how the format of love goes?
Last edited by Buddy4point0 on Fri Jan 14, 2011 2:51 am, edited 1 time in total.
╚»ßuddy4point0 ■
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: How exactly does the love functions work?

Post by TechnoCat »

http://love2d.org/wiki/love.run
It is overridable even.
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: How exactly does the love functions work?

Post by thelinx »

Basically, LÖVE loads the main.lua, then calls love.run.

love.run, by default, calls love.load when the window has been initialized, then starts a loop where it calls love.update, handles events, clears the screen, calls love.draw, and then presents the drawn stuff.

The loop is terminated if the "q" event is pushed by love.event.push.
User avatar
Buddy4point0
Prole
Posts: 35
Joined: Wed Jan 12, 2011 9:29 pm
Location: Virginia

Re: How exactly does the love functions work?

Post by Buddy4point0 »

Thanks! That's exactly what I needed to know.

Now more questions: :P
  • Can you load things and set variables outside of the love.load function?
  • Is it possible to get the color of one pixel on the screen in love? If so what's the function?
  • Can you draw images to another image (for screen effects) for can you only draw images to the screen?
╚»ßuddy4point0 ■
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: How exactly does the love functions work?

Post by thelinx »

Buddy4point0 wrote:Can you load things and set variables outside of the love.load function?
Yes.
Is it possible to get the color of one pixel on the screen in love? If so what's the function?
No. You can however get the colour of a pixel from an ImageData.
Can you draw images to another image (for screen effects) for can you only draw images to the screen?
ImageData:Paste might be what you're looking for.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: How exactly does the love functions work?

Post by TechnoCat »

thelinx wrote:
Is it possible to get the color of one pixel on the screen in love? If so what's the function?
No. You can however get the colour of a pixel from an ImageData.
With one more step inbetween you can: http://love2d.org/wiki/love.graphics.newScreenshot
User avatar
Buddy4point0
Prole
Posts: 35
Joined: Wed Jan 12, 2011 9:29 pm
Location: Virginia

Re: How exactly does the love functions work? [more question

Post by Buddy4point0 »

Thanks again, and sorry for making you guys send me links from the wiki. I looked on there but I was having trouble finding everything that I need.
╚»ßuddy4point0 ■
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: How exactly does the love functions work?

Post by Robin »

thelinx wrote:Basically, LÖVE loads the main.lua, then calls love.run.
Wow, I didn't know about the [wiki] tag! That's incredibly useful!
Help us help you: attach a .love.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: How exactly does the love functions work? [more question

Post by BlackBulletIV »

You mean there's a wiki tag? Awesome. Let's try it: love.
EDIT: Yay it works!
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: How exactly does the love functions work? [more question

Post by Robin »

But it doesn't work if there's a : in the title, which was how I saw it existed:
thelinx wrote:ImageData:Paste might be what you're looking for.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Google [Bot], zorg and 7 guests