#pragma config(StandardModel, "EV3_REMBOT")
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/*
Use the buttons on the EV3 brick to program the robot to move around. 5 commands can
be entered into the EV3 brick.
Left Button 	= 1
Right Button  = 3
Up Button 		= 4
Down Button  	= 5
*/

int drive[5];

task main()
{
	for(int i = 0; i < 5; i++) //i = i + 1
	{
		while(getButtonPress(buttonAny) == 0)
		{
			//Wait for Any Button to be pressed.
		}
		if(getButtonPress(buttonLeft) == 1)						drive[i] = 1;
		else if(getButtonPress(buttonRight) == 1)			drive[i] = 3;
		else if(getButtonPress(buttonUp) == 1)				drive[i] = 4;
		else if(getButtonPress(buttonDown) == 1)			drive[i] = 5;

		playSoundFile("Click");
		while(bSoundActive)
		{
			sleep(10);
		}

		while(getButtonPress(buttonAny) == 1)
		{
			//Wait for All Buttons to be released.
			sleep(10);
		}
	}

	sleep(2000);
	playSoundFile("Go");
	while(bSoundActive)
	{
		sleep(10);
	}

	for(int i = 0; i < 5; i++)
	{
		if(drive[i] == 1)
		{
			//Turn Left Code.
			moveMotorTarget(motorC, 360, 50);
			waitUntilMotorStop(motorC);

		}
		else if(drive[i] == 3)
		{
			//Turn Right Code.
			moveMotorTarget(motorB, 360, 50);
			waitUntilMotorStop(motorB);
		}
		else if(drive[i] == 4)
		{
			//Forward Code.
			moveMotorTarget(motorB, 360, 50);
			moveMotorTarget(motorC, 360, 50);
			waitUntilMotorStop(motorB);
			waitUntilMotorStop(motorC);
		}
		else if(drive[i] == 5)
		{
			//Backward Code.
			moveMotorTarget(motorB, -360, -50);
			moveMotorTarget(motorC, -360, -50);
			waitUntilMotorStop(motorB);
			waitUntilMotorStop(motorC);
		}
	}

	playSoundFile("Game over");
	while(bSoundActive)
	{
		sleep(10);
	}
}
