- 追加された行はこの色です。
- 削除された行はこの色です。
[[2006b/A6/R Room]]
*「弥」のプログラム [#v6b1283a]
**ペンに関する定義 [#e86aa121]
#define pen_down OnRev(OUT_A);Wait(100);Off(OUT_A) //ペンを下げる
#define pen_up OnFwd(OUT_A);Wait(100);Off(OUT_A) //ペンを上げる
**移動に関する定義 [#ze5276e9]
#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 st Off(OUT_B+OUT_C) // 止まる
**時間に関する定義 [#jfc84386]
#define time_a 50
#define time_b 25
#define time_c 40
#define time_d 50
#define time_e 10
#define time_f 40
#define time_g 40
#define time_h 70
#define time_i 100
#define time_j 20
**サブ・ルチーン [#qe88b3e5]
sub turn_right() //右に90°回転
{ move_right;
Wait(89);
}
sub turn_left() //左に90°回転
{ move_left;
Wait(89);
}
**メイン・プログラム [#c21dc0e8]
task main()
{
「ペン」に関する定義
#define pen_down OnFwd(OUT_A);Wait(100);Off(OUT_A) // ペンを下ろす
#define pen_up OnRev(OUT_A);Wait(100);Off(OUT_A) // ペンを上げる
***「弥」の一画目 [#i22574ee]
pen_down;
move_up;
Wait(time_a);
turn_right();
move_up;
Wait(time_b);
st;
pen_up;
Wait(100);
***二画目までの移動 [#k5f032f6]
「移動」に関する定義
#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) // 止まる
turn_right();
move_up;
Wait(time_a);
st;
***「弥」の二画目 [#aec3c7bf]
pen_down;
Wait(100);
move_down;
Wait(time_a);
st;
pen_up;
Wait(100);
***三画目までの移動 [#m1153c91]
move_up;
Wait(time_a);
st;
turn_left();
st;
***「弥」の三画目 [#h3c411a7]
pen_down;
Wait(100);
move_up;
Wait(time_b);
st;
turn_left();
Wait(100);
move_up;
Wait(time_c);
st;
turn_right();
Wait(100);
move_up;
Wait(time_d);
move_right;
Wait(90);
st;
Wait(100);
move_up;
Wait(time_e);
move_stop;
pen_up;
Wait(200);
***四画目までの移動 [#wac948b4]
move_down;
Wait(time_e);
st;
move_left;
Wait(120);
repeat(2){
turn_left();
}
st;
Wait(100);
move_up;
Wait(time_b+time_b+time_d+20);
move_stop;
Wait(100);
turn_right();
Wait(100);
move_up;
Wait(time_f);
move_stop;
Wait(100);
move_right;
Wait(100);
st;
Wait(200);
***「弥」の四画目 [#qa6b85da]
pen_down;
Wait(100);
move_up;
Wait(time_g);
move_stop;
Wait(100);
pen_up;
Wait(100);
***五画目までの移動 [#ndf71f36]
move_down;
Wait(50);
st;
Wait(100);
move_left;
Wait(100);
st;
Wait(200);
***「弥」の五画目 [#bc6fe68f]
pen_down;
Wait(100);
move_up;
Wait(time_h);
st;
pen_up;
Wait(100);
***六画目までの移動 [#pf56004a]
move_down;
Wait(35);
st;
Wait(100);
turn_right();
st;
Wait(100);
***「弥」の六画目 [#ladbd16b]
pen_down;
Wait(100);
move_up;
Wait(time_i);
st;
move_right;
Wait(100);
st;
Wait(100);
move_up;
Wait(time_e);
move_stop;
pen_up;
Wait(100);
***七画目までの移動 [#u3bf5877]
move_down;
Wait(time_e);
st;
move_left;
Wait(100);
repeat(2)
{
turn_left() ;
}
Wait(100);
move_up;
Wait(80);
st;
turn_left();
Wait(100);
move_up;
Wait(50);
st;
move_left;
Wait(70);
st;
Wait(100);
***「弥」の七画目 [#h03bb7ae]
pen_down;
Wait(100);
move_up;
Wait(time_j);
move_stop;
pen_up;
***八画目までの移動 [#t1771dab]
Wait(100);
move_down;
Wait(time_j);
st;
move_right;
Wait(70);
repeat(2)
{
turn_right();
}
Wait(100);
move_up;
Wait(100);
st;
move_right;
Wait(70);
st;
Wait(100);
***「弥」の八画目 [#f32893ac]
pen_down;
Wait(100);
move_up;
Wait(time_j);
move_stop;
pen_up;
***中心までの移動 [#g786596d]
Wait(100);
move_right;
Wait(100);
move_up;
Wait(200);
move_stop;
}
「時間」に関する定義
#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)
コメントお願いします。。。
#comment
サブルーチン
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; // ゆっくり止まる
}
// 終了