Ok maybe i'm stupid
Ok maybe i'm stupid
but why have love.update and love.draw be separate functions? they're both called every frame, correct? update before draw, right? so why have them be separate?
four years later and i hate remembering the posts i made on here exist but i can't delete any of them or my account
sorry you had to read this
sorry you had to read this
Re: Ok maybe i'm stupid
first because they are supposed to do very different things and therefore should logically be seperate. And secondly, with a custom love.run they might not both run every frame at all.FRII wrote:but why have love.update and love.draw be separate functions? they're both called every frame, correct? update before draw, right? so why have them be separate?
Re: Ok maybe i'm stupid
There's nothing inherently different about them. They're just split into update and draw for the sake of good organization. Also, update has the dt argument and draw doesn't, which reinforces that good organization.
Re: Ok maybe i'm stupid
so what y'all're sayin' is that the title is more a definite than a an inquisitive statement
four years later and i hate remembering the posts i made on here exist but i can't delete any of them or my account
sorry you had to read this
sorry you had to read this
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Ok maybe i'm stupid
More like the knowledge you lacked is now gained.
Now get back to work : 3
Now get back to work : 3
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: Ok maybe i'm stupid
They don't have to be separate. You could do all your updating in love.draw (actually some people do for technical reasons.) The only reason they are separate afaik is because of preference.FRII wrote:but why have love.update and love.draw be separate functions? they're both called every frame, correct? update before draw, right? so why have them be separate?
- unrecoverable
- Prole
- Posts: 4
- Joined: Thu Nov 12, 2015 4:19 pm
Re: Ok maybe i'm stupid
They're separated so that it's easier to prevent game logic from interfering with what's displayed on screen. Without that distinction you just have to be more careful all your game logic is running before your display code.
Re: Ok maybe i'm stupid
Isn't love.draw() the only function that will put anything on the screen when love.graphics functions such as rectangle() are called?
Further emphasizing the organization aspect.
Further emphasizing the organization aspect.
- zorg
- Party member
- Posts: 3468
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Ok maybe i'm stupid
That's only because of what's inside the default love.run anyway.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Ok maybe i'm stupid
One reason to split update from draw: when you drag a window around, some operating systems will force it to redraw more frequently than it otherwise would. If the game can't redraw on demand, the window will flicker or turn black while it moves. I don't think Love2D does this by default, but you could make the draw function run when the OS requests a redraw, meaning it'd be running more often than the update function (and no flickering windows!)
Who is online
Users browsing this forum: No registered users and 4 guests