Game Development Community

Schedule related to graphic updates

by Bruno · in Torque Game Builder · 09/06/2007 (3:18 pm) · 1 replies

Hi,

What i'm tryng to do it should be a rather simple thing, however i can't get this to work whatever i do.,
I'm tryng to "paint" a tilemap of size(20x9) with a tileanimation, but i wanted to "paint" each tile with a little schedule, so it looks like a cascading effect.

This is how my source looks :

function put_tile(%x,%y)
{
myTile.setAnimatedTile(%x,%y,gridsAnimation);
}

function fill_animated_grid()
{
for (%xboard = 1; %xboard < $sizeX +1; %xboard++)
{
for (%yboard = 1; %yboard < $sizeY; %yboard++)
{
schedule(100,0,"put_tile",%xboard,%yboard);
}
}
}

However, it doens't matter how much timing i use in schedule, he just fills the entire tilemap all at once.
Can't this be done like this ?
Is the schedule tied to the rendered in same way, that he puts them all together or something ?
If this isn't the way, how can i do this ?

thanks,
Bruno

#1
09/07/2007 (11:46 am)
This is because you're scheduling all your "put_tiles" simultaneously... so basically what your code is doing is tell it to draw sizeX*sizeY tiles simultaneously at 100 ms.

What you need do to is replace your loop with a sequence of schedules. Something like:
function fill_animated_grid()
{

     put_tile($xboard,$yboard);

     $xboard++;

     //this logic replaces your loop to reset the x at each new y
     if($xboard == $sizeX + 1)
     {
          $xboard  = 1;
          $yboard++;
     }

     //schedule the next drawing until you hit the max
     if($yboard < $sizeY + 1)
          schedule(100,"fill_animated_grid");
}

This may need some debug, but it should give you an idea.