scene_loader.c
void NextTurn(SceneData* scene_data){

	// Change turns
	if(scene_data[CURRENT_SCENE].player_turn == PLAYER_1_TURN){
	
		int new_tank_idx = ReturnIndexToLiveTank(scene_data, PLAYER_2_TURN);
		
		if(new_tank_idx == -1){
			// Player 1 won
			scene_data[CURRENT_SCENE].GameOver = true;
			printf("!GAME OVER! - player 1 won\n");
			return;
		}else{
			
			// Check if We didn't destroy ourselves
			int my_tanks_idx = ReturnIndexToLiveTank(scene_data, PLAYER_1_TURN);
			if(my_tanks_idx == -1){
				// We destroy ourselves
				scene_data[CURRENT_SCENE].player_turn = PLAYER_2_TURN;
				scene_data[CURRENT_SCENE].GameOver = true;
				printf("!GAME OVER! - player 2 won\n");
				return;
			}
		
		
			scene_data[CURRENT_SCENE].Player_2_tank_ptr = new_tank_idx;
			scene_data[CURRENT_SCENE].player_turn = PLAYER_2_TURN;
			
			// Set the active tank
			scene_data[CURRENT_SCENE].active_tank = &(scene_data[CURRENT_SCENE].player_2_tanks_obj[new_tank_idx]);
		}
		
	}else{
	
		int new_tank_idx = ReturnIndexToLiveTank(scene_data, PLAYER_1_TURN);
		
		if(new_tank_idx == -1){
			// Player 2 won
			scene_data[CURRENT_SCENE].GameOver = true;
			printf("!GAME OVER! - player 2 won\n");
			return;
		}else{
		
			
			// Check if We didn't destroy ourselves
			int my_tanks_idx = ReturnIndexToLiveTank(scene_data, PLAYER_2_TURN);
			if(my_tanks_idx == -1){
				// We destroy ourselves
				scene_data[CURRENT_SCENE].player_turn = PLAYER_1_TURN;
				scene_data[CURRENT_SCENE].GameOver = true;
				printf("!GAME OVER! - player 1 won\n");
				return;
			}
		
		
			scene_data[CURRENT_SCENE].Player_1_tank_ptr = new_tank_idx;
			scene_data[CURRENT_SCENE].player_turn = PLAYER_1_TURN;
			
			// Set the active tank
			scene_data[CURRENT_SCENE].active_tank = &(scene_data[CURRENT_SCENE].player_1_tanks_obj[new_tank_idx]);
		}
	}
	
	// Set new wind speed if the wind is on
	if(scene_data[CURRENT_SCENE].wind_on){
		SetWindSpeed(scene_data);
	}
	
	scene_data[CURRENT_SCENE].turn_count++;
	ResetTanksMoveLimit(scene_data);
	// Reset our 'confirm movement' bool var
	scene_data[CURRENT_SCENE].movement_confirmed = false;
	
	return;
}
/*  This function changes the tank and player in control  */
This function changes the tank and player in control
This function changes the tank and player in control
void NextTurn(SceneData* scene_data){
	if(scene_data[CURRENT_SCENE].player_turn == PLAYER_1_TURN){
		int new_tank_idx = ReturnIndexToLiveTank(scene_data, PLAYER_2_TURN);
		if(new_tank_idx == -1){
			scene_data[CURRENT_SCENE].GameOver = true;
			printf("!GAME OVER! - player 1 won\n");
			return;
		}else{
			int my_tanks_idx = ReturnIndexToLiveTank(scene_data, PLAYER_1_TURN);
			if(my_tanks_idx == -1){
				scene_data[CURRENT_SCENE].player_turn = PLAYER_2_TURN;
				scene_data[CURRENT_SCENE].GameOver = true;
				printf("!GAME OVER! - player 2 won\n");
				return;
			}
			scene_data[CURRENT_SCENE].Player_2_tank_ptr = new_tank_idx;
			scene_data[CURRENT_SCENE].player_turn = PLAYER_2_TURN;
			scene_data[CURRENT_SCENE].active_tank = &(scene_data[CURRENT_SCENE].player_2_tanks_obj[new_tank_idx]);
		}
	}else{
		int new_tank_idx = ReturnIndexToLiveTank(scene_data, PLAYER_1_TURN);
		if(new_tank_idx == -1){
			scene_data[CURRENT_SCENE].GameOver = true;
			printf("!GAME OVER! - player 2 won\n");
			return;
		}else{
			int my_tanks_idx = ReturnIndexToLiveTank(scene_data, PLAYER_2_TURN);
			if(my_tanks_idx == -1){
				scene_data[CURRENT_SCENE].player_turn = PLAYER_1_TURN;
				scene_data[CURRENT_SCENE].GameOver = true;
				printf("!GAME OVER! - player 1 won\n");
				return;
			}
			scene_data[CURRENT_SCENE].Player_1_tank_ptr = new_tank_idx;
			scene_data[CURRENT_SCENE].player_turn = PLAYER_1_TURN;
			scene_data[CURRENT_SCENE].active_tank = &(scene_data[CURRENT_SCENE].player_1_tanks_obj[new_tank_idx]);
		}
	}
	if(scene_data[CURRENT_SCENE].wind_on){
		SetWindSpeed(scene_data);
	}
	scene_data[CURRENT_SCENE].turn_count++;
	ResetTanksMoveLimit(scene_data);
	scene_data[CURRENT_SCENE].movement_confirmed = false;
	return;
}
void NextTurn ( SceneData * scene_data ) { if ( scene_data [ CURRENT_SCENE ] . player_turn == PLAYER_1_TURN ) { int new_tank_idx = ReturnIndexToLiveTank ( scene_data , PLAYER_2_TURN ) ; if ( new_tank_idx == -1 ) { scene_data [ CURRENT_SCENE ] . GameOver = true ; printf ( " \n " ) ; return ; } else { int my_tanks_idx = ReturnIndexToLiveTank ( scene_data , PLAYER_1_TURN ) ; if ( my_tanks_idx == -1 ) { scene_data [ CURRENT_SCENE ] . player_turn = PLAYER_2_TURN ; scene_data [ CURRENT_SCENE ] . GameOver = true ; printf ( " \n " ) ; return ; } scene_data [ CURRENT_SCENE ] . Player_2_tank_ptr = new_tank_idx ; scene_data [ CURRENT_SCENE ] . player_turn = PLAYER_2_TURN ; scene_data [ CURRENT_SCENE ] . active_tank = & ( scene_data [ CURRENT_SCENE ] . player_2_tanks_obj [ new_tank_idx ] ) ; } } else { int new_tank_idx = ReturnIndexToLiveTank ( scene_data , PLAYER_1_TURN ) ; if ( new_tank_idx == -1 ) { scene_data [ CURRENT_SCENE ] . GameOver = true ; printf ( " \n " ) ; return ; } else { int my_tanks_idx = ReturnIndexToLiveTank ( scene_data , PLAYER_2_TURN ) ; if ( my_tanks_idx == -1 ) { scene_data [ CURRENT_SCENE ] . player_turn = PLAYER_1_TURN ; scene_data [ CURRENT_SCENE ] . GameOver = true ; printf ( " \n " ) ; return ; } scene_data [ CURRENT_SCENE ] . Player_1_tank_ptr = new_tank_idx ; scene_data [ CURRENT_SCENE ] . player_turn = PLAYER_1_TURN ; scene_data [ CURRENT_SCENE ] . active_tank = & ( scene_data [ CURRENT_SCENE ] . player_1_tanks_obj [ new_tank_idx ] ) ; } } if ( scene_data [ CURRENT_SCENE ] . wind_on ) { SetWindSpeed ( scene_data ) ; } scene_data [ CURRENT_SCENE ] . turn_count ++ ; ResetTanksMoveLimit ( scene_data ) ; scene_data [ CURRENT_SCENE ] . movement_confirmed = false ; return ; }
This function changes the tank and player in control
This function changes the tank and player in control
// Change turns // Player 1 won // Check if We didn't destroy ourselves // We destroy ourselves // Set the active tank // Player 2 won // Check if We didn't destroy ourselves // We destroy ourselves // Set the active tank // Set new wind speed if the wind is on // Reset our 'confirm movement' bool var