[[2006b/A6/R Room]]

*「弥」のプログラム [#v6b1283a]

「ペン」に関する定義 
#define pen_down OnFwd(OUT_A);Wait(100);Off(OUT_A) // ペンを下ろす
#define pen_up OnRev(OUT_A);Wait(100);Off(OUT_A) // ペンを上げる

「移動」に関する定義 
#define move_up OnFwd(OUT_B+OUT_C) // 前進
#define move_down OnRev(OUT_B+OUT_C) // 後退
#define move_right OnFwd(OUT_B);OnRev(OUT_C) // 右回転
#define move_left OnFwd(OUT_C);OnRev(OUT_B) // 左回転
#define move_stop Float(OUT_B+OUT_C) // ゆっくり止まる
#define stop Off(OUT_B+OUT_C) // 止まる

「時間」に関する定義 
#define time_a 200 
#define time_b 150
#define time_c 160
#define time_d 250
#define time_e 100
#define time_f 120
#define time_g 170
#define time_h
#define time_i
#define time_j
#define wait(t) Wait(UNITTIME*t)

サブルーチン
sub turn_right() // 右 90°ターン
{
 move_right; // 右回転
 wait(150); // 1.5秒待つ
 } 
sub turn_left() // 左 90°ターン
{
 move_left; // 左回転
 wait(150); // 1.5秒待つ
 }

メインプログラム 
 task main {              

 // 「弥」の1画目
  pen_down; // ペンを下ろす
  move_up; // 前進
  wait(time_a) // 前進維持
  turn_right(); // 右 90°ターン
  move_up; // 前進
  wait(time_b); // 前進維持
  pen_up; // ペンを上げる
  stop; // 止まる
                
 // 「弥」の2画目の位置までの移動
  turn_right; // 右 90°ターン
  move_up; // 前進
  wait(time_a); // 前進維持
  stop; // 止まる
                
 // 「弥」の2画目  
  pen_down; // ペンを下げる
  move_down; // 後退
  wait(time_a); // 後退維持
  stop; // 止まる
  pen_up; // ペンを上げる
               
 // 「弥」の3画目の位置までの移動
  move_up; // 前進
  wait(time_a); // 前進維持
  stop; // 止まる
  turn_left; // 左 90°ターン
  stop; // 止まる
                
 // 「弥」の3画目
  pen_down; // ペンを下ろす
  move_up; // 前進
  wait(time_b); // 前進維持
  stop; // 止まる
  turn_left; // 左 90°ターン
  move_up; // 前進
  wait(time_c); // 前進維持
  stop; // 止まる
  turn_right; // 右 90°ターン
  move_up; // 前進
  wait(time_d); // 前進維持
  move_right; // 右回転
  wait(160); // 回転維持
  move_up; // 前進
  wait(time_e); // 前進維持
  move_stop; // ゆっくり止まる
  pen_up; // ペンを上げる
           
 // 「弥」の4画目の位置までの移動
  move_down; // 後退
  wait(time_e); // 後退維持
  stop; // 止まる
  move_left; // 左回転
  wait(160); // 回転維持
  repeat(2) // 2回繰り返し
 {move_left // 左回転}
 move_up; // 前進
  wait(time_b+time_b+time_d+100); // 前進維持
  move_stop; // ゆっくり止まる
  turn_right; // 右 90°ターン
  move_up; // 前進
  wait(time_f); // 前進維持
  move_stop; // ゆっくり止まる
  move_right; // 右回転
  wait(160); // 回転維持
  stop; // 止まる
                
 // 「弥」の4画目     
  pen_down; // ペンを下ろす
  move_up; // 前進
  wait(time_g); // 前進維持
  move_stop; // ゆっくり止まる
  pen_up; // ペンを上げる
               
 // 「弥」の5画目の位置までの移動  
  move_down; // 後退
  wait(100); // 後退維持
  move_left; // 左回転
  wait(300); // 回転維持
  stop; // 止まる
               
 // 「弥」の5画目  
  pen_down; // ペンを下げる
  move_up; // 前進
  wait(time_h); // 前進維持
  move_stop; // ゆっくり止まる
  pen_up; // ペンを上げる
               
 // 「弥」の6画目の位置までの移動
 move_down; // 後退
  wait(time_h/2); // 後退維持
  stop; // 止まる
  turn_right; // 右 90°ターン
               
 // 「弥」の6画目 
  pen_down; // ペンを下ろす
  move_up; // 前進
  wait(time_i); // 前進維持
  stop; // 止まる
  move_right; // 右回転
  wait(160); // 回転維持
  move_up; // 前進
  wait(time_e); // 前進維持
  move_stop; // ゆっくり止まる
  pen_up; // ペンを上げる
               
 // 「弥」の7画目の位置までの移動
  move_down; // 後退
  wait(time_e); // 後退維持
  stop; // 止まる
  move_left; // 左回転
  wait(160); // 回転維持
  repeat(2) // 2回繰り返し
  {turn_left ;} // 左 90°回転
  move_up; // 前進
  wait(time_2*i/3); // 前進維持
  stop; // 止まる
  turn_left; // 左 90°ターン
  move_up; // 前進
  wait(100); // 前進維持
  stop; // 止まる
  move_left; // 左回転
  wait(100); // 回転維持
  stop; // 止まる
               
 // 「弥」の7画目      
  pen_down; // ペンを下ろす
  move_up; // 前進
  wait(time_j); //前進維持
  move_stop; // ゆっくり止まる
  pen_up; // ペンを上げる
                
 // 「弥」の8画目の位置までの移動
  move_down; // 後退
  wait(time_j); // 後退維持
  stop; // 止まる
  move_right; // 右回転
  wait(100); // 回転維持
  repeat(2) // 2回繰り返し
  {turn_right;} // 右 90°回転
  move_up; // 前進
  wait(200); // 前進維持
  stop; // 止まる
  move_right; // 右回転
  wait(100); // 回転維持
  stop; // 止まる
               
 // 「弥」の8画目 
  pen_down; // ペンを下ろす
  move_up; // 前進
  wait(time_j); // 前進維持
  move_stop; // ゆっくり止まる
  pen_up; // ペンを上げる
                
 //中心までの移動    
  move_right; // 右回転
  wait(150); // 回転維持
  move_up; //前進
  wait(300); //前進維持
  move_stop; // ゆっくり止まる
  } 
// 終了

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS