Page 1 of 1
the best way to wait
Posted: Wed Jan 14, 2009 4:41 am
by osgeld
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 ...
Re: the best way to wait
Posted: Thu Jan 15, 2009 3:51 am
by osgeld
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
Re: the best way to wait
Posted: Thu Jan 15, 2009 4:36 am
by LÖVER
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

Re: the best way to wait
Posted: Thu Jan 15, 2009 2:00 pm
by osgeld
it sleeps the entire thread
Re: the best way to wait
Posted: Thu Jan 15, 2009 2:23 pm
by Tabasco
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.
Re: the best way to wait
Posted: Thu Jan 15, 2009 3:59 pm
by osgeld
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