Re: start a shader effect so it leasts for n time at spawn time

Started by BielBdeLuna, July 18, 2015, 07:44:33 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

BielBdeLuna



a solution to avoid creating several copies of the same code could be:


void whateverhappensinthread( code variables ) {
        while ( true ) {
            code
        }
}

void t_threadcontrol1( code variables ){
        float remember;

        whateverhappensinthread( code variables );

        remember = threadId;
        threadId = 0;


}

BielBdeLuna

a solution to avoid creating several copies of the same code could be:


float thread_controler_1, thread_controler_2;

void whateverhappensinthread( code variables ) {
        while ( true ) {
            code or break
         sys.waitFrame();
        }
}

void t_threadcontrol1( code variables ){
        float remember;

        whateverhappensinthread( code variables );

        remember = thread_controler_1;
        thread_controler_1 = 0;
        sys.terminate( remember );
}

void t_threadcontrol2( code variables ){
        float remember;

        whateverhappensinthread( code variables );

        remember = thread_controler_2;
        thread_controler_2 = 0;
        sys.terminate( remember );
}

void execute() { // this should initiate two different threads alternatively and consecutively
       while ( true ) {

      float next_one = 0;

      if ( next_one == 0 ) {



       sys.waitFrame();

       if ( thread_controler_1 == 0 && thread_controler_2 != 0 ) {
           thread_controler_1 thread = thread t_trheadcontrol1( code variables );
       } else if ( thread_controler_2 == 0 ) {
           thread_controler_2 thread = thread t_trheadcontrol2( code variables );
       }
       sys.waitFrame();
}


so the threads could have a common part ( the whateverhappensinthread function ) and a specific part ( the thread control )