scene_loader.c
int ReturnLiveTankIdx(Tank* tanks, int tanks_count, int old_index){
	int index = old_index;
	
	// If tanks_count reaches zero, that means we iterated full circle
	while(tanks_count > 0){
		// Go to next valid index
		if((index+1) >= tanks_count){
			index = 0;
		}else{
			index++;
		}
		
		// Check if the tank is dead
		if(tanks[index].health <= 0){
			// It's dead
			tanks_count--;
		}else{
			// It's live, return index
			printf("returning tank index: %d\n", index);
			return index;
		}
	}
	return -1;
}
/*  This functions returns the index of the next live tank in array of tanks  
	-1 if there is no live tank.  */
This functions returns the index of the next live tank in array of tanks
1 if there is no live tank.
This functions returns the index of the next live tank in array of tanks 1 if there is no live tank .
int ReturnLiveTankIdx(Tank* tanks, int tanks_count, int old_index){
	int index = old_index;
	while(tanks_count > 0){
		if((index+1) >= tanks_count){
			index = 0;
		}else{
			index++;
		}
		if(tanks[index].health <= 0){
			tanks_count--;
		}else{
			printf("returning tank index: %d\n", index);
			return index;
		}
	}
	return -1;
}
int ReturnLiveTankIdx ( Tank * tanks , int tanks_count , int old_index ) { int index = old_index ; while ( tanks_count > 0 ) { if ( ( index + 1 ) >= tanks_count ) { index = 0 ; } else { index ++ ; } if ( tanks [ index ] . health <= 0 ) { tanks_count -- ; } else { printf ( " \n " , index ) ; return index ; } } return -1 ; }
This functions returns the index of the next live tank in array of tanks
1 if there is no live tank.
This functions returns the index of the next live tank in array of tanks 1 if there is no live tank .
// If tanks_count reaches zero, that means we iterated full circle // Go to next valid index // Check if the tank is dead // It's dead // It's live, return index