## the best way to wait

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.
osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

### the best way to wait

ok, im tired tonight and not really in a coding frame of mind and i cant at this moment figure this out ... so while my brain recharges let me ask how YOU would do it

4 images, right now they all blob on the screen at once

what i would like to do is

draw image 1
wait X time
draw image 2
wait Y time
ect

how its setup now is the images slide into place with their positions updated in the update(dt) function, and their new positions are drawn to the screen, and i guess i could make images 2-4 start sooo far off screen the delay just happens, but thats kinda crappy ...

osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

### Re: the best way to wait

after piddle squatting with it another night i found that i was over complicating the whole process with a set function a wait function a friggin table of vales, flags, switches 2 kitchen sinks and a partridge in a pear tree

turns out, since i havent been sleeping all that well the last couple nights, that makes me an even more sucky scripter

here is what i deem as the easy way

Code: Select all

if counter <= 10 then
counter = counter + (10 * dt)
else
update_game_over_text(dt)
end

im going to bed early

LÖVER
Prole
Posts: 10
Joined: Mon Jan 05, 2009 9:09 pm

### Re: the best way to wait

Could't you do

Code: Select all

if timeToWait == true then
love.timer.sleep(50)
end

I dunno if that sleeps the entire thread or if it acts as an actual timer. If it sleeps the entire thread then we need a timer function

osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

### Re: the best way to wait

it sleeps the entire thread

Tabasco
Citizen
Posts: 72
Joined: Tue Dec 02, 2008 5:04 pm

### Re: the best way to wait

You could make your own image or tile class and assign it an internal delay and then just use tile:update(dt) and tile:draw() where internally it's doing something like

Code: Select all

function tile:update(frametime)
self.lifetime = self.lifetime + frametime
if not self.active and self.lifetime >= self.starttime then
self.active = true
end
if not self.active then return end
...
end

You would set starttime when you instantiated the tile and the tile itself knows to wait until then to do anything. It doesn't perform movement logic until it's 'active' and in draw you would exit the function if it isn't active yet as well.

osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

### Re: the best way to wait

yea thats where i started to go, but ive been brain damaged the last couple of nights

infact i really need to rewrite the whole sequence, as it is now its hard coded to each and every little thing, and its quite large, mainly to use as a mockup to see if it was even what i wanted (and it is)

so i need to sit down, make it all generic and then i will decide which is going to be the best in this situation

and thanks for the input guys, if anyone else has another idea feel free to let me know, you can always teach me a new trick

### Who is online

Users browsing this forum: RagingDave and 14 guests