|
|
Array |
|
Back |
extern
void object::Array( )
{
errmode(0);
int array[5];
float dir = 90;
// First action:
// bring objects to the base
for ( int i=1 ; i<6 ; i=i+1 )
{
move(5); // move to
next position
grab(); // pick
up object
if ( load == null )
{
array[i-1] = 0; //
nothing to pick up
}
else
{
// store object info
in array
array[i-1] = load.category;
// move back to platform
move(-i*5);
turn(dir);
drop(); //
put object down
turn(-dir);
dir += 90;
if ( i == 5 ) break;
// come back if there's
more to do
move(i*5);
}
} errmode(1);
// Second action:
// bring objects back in reverse order
for ( int i=0 ; i<5 ; i=i+1 )
{
if ( array[i] == 0 ) continue;
// find object
object item = radar(array[i]);
dir = direction(item.position);
turn(dir); //
turn towards object
grab(); //
pick it up
turn(-dir); // turn
towards path
move(5*(5-i)); // move
to new position
drop(); //
put object down
move(5*(i-5));
}
} |
|