Love Tutorials on headchant.com

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Love Tutorials on headchant.com

Post by tentus »

It's a 50 line program with a slightly tweaked conf.lua I copied from my dropbox: it's not that hard to do, you just have to concentrate a bit. :) Due to blizzard conditions, I spend a fair bit of time on the bus this time of year. The hardest part is remembering the love functions exactly right, but after enough hours they become second nature, like riding a bike.
Kurosuke needs beta testers
trlestew
Prole
Posts: 9
Joined: Sun Dec 12, 2010 6:55 pm

Re: Love Tutorials on headchant.com

Post by trlestew »

I followed the little tutorial you made.

Drawing comes after updating?
That confuses me. I'm still relatively new to programming in whole, not just lua.
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: Love Tutorials on headchant.com

Post by nevon »

trlestew wrote:Drawing comes after updating?
That confuses me. I'm still relatively new to programming in whole, not just lua.
Yes, drawing comes after updating. Why does that seem confusing to you?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Love Tutorials on headchant.com

Post by Robin »

trlestew wrote:I followed the little tutorial you made.

Drawing comes after updating?
That confuses me. I'm still relatively new to programming in whole, not just lua.
"updating" means the "world" is updated, the underlying objects are changed, not the screen. That happens in draw.
Help us help you: attach a .love.
trlestew
Prole
Posts: 9
Joined: Sun Dec 12, 2010 6:55 pm

Re: Love Tutorials on headchant.com

Post by trlestew »

Could you give an example of how updating would be used so I could grasp around it better?
I'm still not understanding.
ShadowProtocol
Prole
Posts: 15
Joined: Thu Nov 25, 2010 9:41 pm

Re: Love Tutorials on headchant.com

Post by ShadowProtocol »

The game programming basics involve (in every game) two main steps, Update and Draw.

This is not just a LOVE thing.

Think of "Update" as the step that takes the time since the last frame, and uses it to handle calculations based on other factors, such as the speed of a character.

If a character's state is said to be moving right, you will take his variable that handles his location (in the X direction in this case) and add to it. The variable is changed (or UPDATED) in this step. The Update function is sometimes referred to as the Logic step.

Now that the characters X variable has been modified, you will want to see the changes, so the Draw step comes after.

It only makes sense to change what the user SEES after the objects in the game have been MODIFIED OR UPDATED in some way.

Hope that clears it up somewhat.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Love Tutorials on headchant.com

Post by tentus »

trlestew wrote:Could you give an example of how updating would be used so I could grasp around it better?
I'm still not understanding.
Think of your game like a math problem that you're working out for someone. There are two parts to demonstrating a math problem: actually figuring it out yourself, and then writing it down so the other person can see and understand it. Usually the two steps are intertwined, with you writing stuff down immediately after you figure it out.

So, Update is the actual number crunching that you do in your head. This is where the real work is getting done, but it's invisible to to the other person.

Draw is you writing it down so they can see it. You're not crunching any numbers, but showing them to the other person.

In Love, Update and Draw are called one after another as often as possible. So, extending our math problem example, it's as if the other person is asking us questions (player input via keyboard or mouse) and we think of an answer (in update) and show it to them (in draw).
Kurosuke needs beta testers
trlestew
Prole
Posts: 9
Joined: Sun Dec 12, 2010 6:55 pm

Re: Love Tutorials on headchant.com

Post by trlestew »

Alright, that makes more sense :)

But what about when you're drawing something such as a logo? Wouldn't you draw first before updating since there is no real interaction with it?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Love Tutorials on headchant.com

Post by Robin »

trlestew wrote:But what about when you're drawing something such as a logo? Wouldn't you draw first before updating since there is no real interaction with it?
It's not interaction that matters. It matters whether the computer has to "think". And it has to think about where the logo would go (it could bounce around!) or how much time is left to show the logo…
Help us help you: attach a .love.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Love Tutorials on headchant.com

Post by kikito »

It's easier to think about love.draw and love.update if you think about your game as a claymation (like this one) or a stop-motion picture.

love.update is where you 'prepare' the scene. It's when you go and "change things": this tree must have moved slightly to the left. The color of this guy's clothes will change a bit. And the lights will move up a centimeter.

But instead of physically moving objects, you just modify variables - You change the value of the variables tree.x, guy.clothes.color and light.up, for example.

love.draw is similar to the act of "taking a picture" from your modified scene. But instead of using a camera, you just use the variables that you modified on the love.update function to draw things. For example, you write things like "draw a black rectangle where the variables tree.x, tree.y indicate, and a green circle on top of it".

In the case of a logo being shown, love.update will probably need to do something, the logo is completely static. Even the slightest animation (for example moving the logo a little bit, or making a fade to black) will require love.update to change the values of variables.
When I write def I mean function.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest