sub The_slide()
{SetPower(OUT_C,10);OnFwd(OUT_C);Wait(10);Float(OUT_C);Wait(200);OnRev  (OUT_C);Wait(60);Float(OUT_C);Wait(200);
}
sub Keep_slide()
{;OnRev(OUT_C);Wait(30);Off(OUT_C);
}
sub Ride()
{OnRev(OUT_A);Wait(50);Off(OUT_A);OnFwd(OUT_B);Wait(50);
Off(OUT_B);OnFwd(OUT_A);Wait(60);Off(OUT_A);
}
sub Push()
{OnFwd(OUT_A);Wait(10);OnRev(OUT_A);Wait(10);Off(OUT_A);
}
sub Descend()
{OnFwd(OUT_B);Wait(50);Off(OUT_B);OnRev(OUT_A);Wait(200);Off(OUT_A); 

OnRev(OUT_B);Wait(20);Off(OUT_B); }

sub Sound_Message()
{ PlaySound(SOUND_DOUBLE_BEEP) ;}
sub Sound_Sensor()
{PlaySound(SOUND_CLICK);}
#define floor_distinction SENSOR_1
#define box_distinction SENSOR_2
#define Black SENSOR_2<41
#define White 52<SENSOR_2
#define Green 45<SENSOR_2<50
#define body OUT_B
#define beetle OUT_A
task main()
{int i;
SetSensor(floor_distinction, SENSOR_LIGHT); 
SetSensor(box_distinction, SENSOR_LIGHT);         
until(Message()==1); Sound_Message();                                         //<1>1
for(i=1;i<=20;i++){SendMessage(2);}; 
Wait(50);
OnRev(body);                               
until(floor_distinction<48);Sound_Sensor(); 
Off(body); 
OnRev(beetle);                             //2
Wait(180);
Off(beetle);
Wait(800); 
OnFwd(beetle);Wait(50);OnRev(beetle);Wait(30);OnFwd(beetle);    //3                                    
Wait(200);
Off(beetle);
repeat(3){OnRev(beetle);Wait(100);Off(beetle);
if(Black)                                                 
{Wait(20);The_slide();Keep_slide();Wait(100);}
if(White)
{OnFwd(body);Wait(30);until(floor_distinction<48);Sound_Sensor();Off(body); 
Wait(20);The_slide();Keep_slide();
OnRev(body);Wait(30);until(floor_distinction<48);Off(body);Wait(100);}
if(Green)
{OnFwd(body);Wait(30);until(floor_distinction<48);Sound_Sensor();Wait (30);until(floor_distinction<48);Sound_Sensor();

;Off(body);

Wait(20);The_slide();Keep_slide();
OnRev(body);Wait(30);until(floor_distinction<48);Wait(30);Sound_Sensor ();until(floor_distinction<48);Sound_Sensor();
Off(body);Wait(100);}
OnRev(beetle);Wait(100);Off(beetle);Wait(200);OnFwd(beetle);Wait(50);OnRev (beetle);Wait(30);OnFwd(beetle);                                     
Wait(200);
Off(beetle);
}
OnFwd(beetle);Wait(30);until(floor_distinction<48);Off(body);
until(Message()==6); Sound_Message();                                         //<2>1
for(i=1;i<=20;i++){SendMessage(7);};
Wait(50);
OnRev(body);                               
until(floor_distinction<48);Sound_Sensor();
Off(body);
OnRev(beetle);                             //2
Wait(180);
Off(beetle);
Wait(800);
OnFwd(beetle);Wait(50);OnRev(beetle);Wait(30);OnFwd(beetle);    //3                                    
Wait(200);
Off(beetle);
repeat(3){OnRev(beetle);Wait(100);Off(beetle);
if(Black)                                                 
{Wait(20);The_slide();Keep_slide();Wait(100);}
if(White)
{OnFwd(body);Wait(30);until(floor_distinction<48);Sound_Sensor();Off(body);
Wait(20);The_slide();Keep_slide();
OnRev(body);Wait(30);until(floor_distinction<48);Off(body);Wait(100);}
if(Green)
{OnFwd(body);Wait(30);until(floor_distinction<48);Sound_Sensor();Wait (30);until(floor_distinction<48);Sound_Sensor();

;Off(body);

Wait(20);The_slide();Keep_slide();
OnRev(body);Wait(30);until(floor_distinction<48);Wait(30);Sound_Sensor ();until(floor_distinction<48);Sound_Sensor();
Off(body);Wait(100);}
OnRev(beetle);Wait(100);Off(beetle);Wait(200);OnFwd(beetle);Wait(50);OnRev (beetle);Wait(30);OnFwd(beetle);                                     
Wait(200);
Off(beetle);
};}

#define JJ OUT_C

#define seesaw OUT_B

#define body OUT_A

#define floor_distinction SENSOR_3

#define Right OnFwd

#define Left OnRev

#define Up OnFwd

#define Down OnRev

#define Go OnRev

#define Back OnFwd

task main() {int i; SetSensor(floor_distinction, SENSOR_LIGHT);

Back(JJ);Wait(50);Go(JJ);Wait(30);Back(JJ);Wait(80);Go(JJ);Wait(50);Off(JJ); for(i=1;i<=20;i++){SendMessage(1);} ; //<1>1 until(Message()==2);Right(body);until(floor_distinction<48);PlaySound(SOUND_CLICK);Wait(30);until(floor_distinction<48);PlaySound(SOUND_CLICK);Wait(50);Off(body);

Go(JJ);Wait(50);Off(JJ); //2 Left(body);Wait(30);Off(body); Up(seesaw);Wait(20);Back(JJ);Wait(50);Off(JJ);

Back(JJ);Wait(150);Off(JJ);Wait(800);Back(JJ);Wait(10);Off(JJ); //3

Wait(800);Back(JJ);Wait(10);Go(JJ);Wait(50);Off(JJ);

Left(body);Wait(30);until(floor_distinction<48);PlaySound(SOUND_CLICK);Wait(50);Off(body); //4 Wait(500);

for(i=1;i<=20;i++){SendMessage(6);} ; //<2>1 until(Message()==7);Left(body);until(floor_distinction<48);PlaySound(SOUND_CLICK);Off(body);

Go(JJ);Wait(50);Off(JJ); //2 Left(body);Wait(30);Off(body); Up(seesaw);Wait(20);Back(JJ);Wait(50);Off(JJ);

Left(body);Wait(30);until(floor_distinction<48);PlaySound(SOUND_CLICK); //3 Wait(30);until(floor_distinction<48);PlaySound(SOUND_CLICK);Off(body);

Left(body);Wait(30);until(floor_distinction<48);PlaySound(SOUND_CLICK);Wait(50);Off(body); //4 Wait(100);

}


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2006-02-12 (日) 13:51:42