Delay on a loop?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Delay on a loop?

Post by micha »

Sure. Here you go.
I added some comments to the code. If you have any questions feel free to ask. To view the source code, rename the .love file to .zip and unzip it.
Attachments
delay.love
(385 Bytes) Downloaded 160 times
Findo777
Prole
Posts: 36
Joined: Tue Feb 25, 2014 4:09 am

Re: Delay on a loop?

Post by Findo777 »

Cool!
And for the part of source code....?
When I click the download, it shows only the game.
How would I "zip" it?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Delay on a loop?

Post by Robin »

Rename delay.love to delay.zip. Or drag the .love file on the archiving application you use, that'll probably work too.
Help us help you: attach a .love.
User avatar
Jeeper
Party member
Posts: 611
Joined: Tue Mar 12, 2013 7:11 pm
Contact:

Re: Delay on a loop?

Post by Jeeper »

In other words, a .love is just a .zip, but it has been renamed so that your operating system knows that it is supposed to open this file with löve2d by default.
Findo777
Prole
Posts: 36
Joined: Tue Feb 25, 2014 4:09 am

Re: Delay on a loop?

Post by Findo777 »

How do I rename it?
:p
I try right clicking, but it doesn't show rename as an option.

:cry:
Findo777
Prole
Posts: 36
Joined: Tue Feb 25, 2014 4:09 am

Re: Delay on a loop?

Post by Findo777 »

Ok, I see the code.
Thank you, I understand now, but,
how could I make it less than 1 second?
like... .5?
User avatar
Jeeper
Party member
Posts: 611
Joined: Tue Mar 12, 2013 7:11 pm
Contact:

Re: Delay on a loop?

Post by Jeeper »

Findo777 wrote:Ok, I see the code.
Thank you, I understand now, but,
how could I make it less than 1 second?
like... .5?

Code: Select all

function love.update(dt)
    updateStuff(dt)
end



Local timer = 0.5
function updateStuff(dt)
   timer = timer - dt
   if timer < 0 then
      --Do stuff
   end
end
Findo777
Prole
Posts: 36
Joined: Tue Feb 25, 2014 4:09 am

Re: Delay on a loop?

Post by Findo777 »

how would that change it?
isn't dt one every second?

So..................


0.5 - 1 = -0.5
1 - 1 = 0


0 is the same or bigger in each one :P
Wojak
Party member
Posts: 134
Joined: Tue Jan 24, 2012 7:15 pm

Re: Delay on a loop?

Post by Wojak »

Findo777 wrote:how would that change it?
isn't dt one every second?

So..................


0.5 - 1 = -0.5
1 - 1 = 0


0 is the same or bigger in each one :P
dt is 1/FPS so if you running the game at 1 frame per second dt will be 1 but if you running it with 60 it will be 0,017 and love.update is not called once per second but once per frame, that is why dt it is the best way for measuring time ;)
User avatar
Jeeper
Party member
Posts: 611
Joined: Tue Mar 12, 2013 7:11 pm
Contact:

Re: Delay on a loop?

Post by Jeeper »

Findo777 wrote:how would that change it?
isn't dt one every second?

So..................


0.5 - 1 = -0.5
1 - 1 = 0


0 is the same or bigger in each one :P
Nope, dt stands for Delta Time, the time between each frame.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 254 guests