NXC memory game not working.
Posted: 05 Jan 2011, 15:05
Hi,
I'm trying to create a memory game based on colours. I wrote this code and BricxCC compiles it but when i run it in my NXT ti shows a file error:
the code is this:
I'm trying to create a memory game based on colours. I wrote this code and BricxCC compiles it but when i run it in my NXT ti shows a file error:
the code is this:
Code: Select all
task main()
{
SetSensorColorFull(IN_1);
int random[4];
int color[4];
int v = 1;
int j = 1;
int i =1;
int result = 0;
for(v = 1; v <= 4 ; v++)
{ random[v]= Random(3) + 2;
if (random[v] == 2)
{ TextOut (0, LCD_LINE3, "Azul");}
else if (random[v] == 3)
{ TextOut (0, LCD_LINE3, "Verde");}
else if (random[v] == 4)
{ TextOut (0, LCD_LINE3, "Amarillo");}
else
{ TextOut (0, LCD_LINE3, "Rojo");}
}
Wait(10000);
for(;j <=4; j++)
{
RotateMotor(OUT_A, 100,360);
color[j] = Sensor(IN_1)
}
for(; i<=4; i++)
{ switch(color[i])
{
case 2:
TextOut (0, LCD_LINE3, "Azul");
break;
case 3:
TextOut (0, LCD_LINE4, "Verde");
break;
case 4:
TextOut (0, LCD_LINE5, "Amarillo");
break;
case 5:
TextOut (0, LCD_LINE6, "Rojo");
break;
}
if (color[i] != random[i])
{ result +=1;}
}
if (result > 0)
{TextOut (0, LCD_LINE3, "Wrong!"); }
else
{TextOut (0, LCD_LINE3, "Well done!");}
Wait(5000);
}