めいん

Dependencies:   mbed

Committer:
choutin
Date:
Sun Aug 28 17:03:34 2016 +0000
Revision:
0:df2659fd8031
Child:
1:a1e592eca305
???

Who changed what in which revision?

UserRevisionLine numberNew contents of line
choutin 0:df2659fd8031 1 //受渡前での妨害に対応したい
choutin 0:df2659fd8031 2
choutin 0:df2659fd8031 3 #include"header.h"
choutin 0:df2659fd8031 4
choutin 0:df2659fd8031 5 int main(void){
choutin 0:df2659fd8031 6
choutin 0:df2659fd8031 7
choutin 0:df2659fd8031 8 move(0,0);
choutin 0:df2659fd8031 9 close_arm();
choutin 0:df2659fd8031 10 /*以下redteamのフィールドマップを読み込む(mm)
choutin 0:df2659fd8031 11
choutin 0:df2659fd8031 12 blue team の場合はすべてのy座標に(-1)をかける
choutin 0:df2659fd8031 13
choutin 0:df2659fd8031 14 */
choutin 0:df2659fd8031 15
choutin 0:df2659fd8031 16 //オブジェクトの位置
choutin 0:df2659fd8031 17 //原点はスタートゾーンの中心
choutin 0:df2659fd8031 18 int targetx[9] = { 600,600,600,1200,900,1200,900,1200,900 };
choutin 0:df2659fd8031 19 int targety[9] = { blue()*300,blue()*600,blue()*900,blue()*1200,blue()*900,blue()*600,blue()*600,0,blue()*300 };
choutin 0:df2659fd8031 20
choutin 0:df2659fd8031 21 //ハブの位置
choutin 0:df2659fd8031 22 int hub1x = 600;
choutin 0:df2659fd8031 23 int hub1y = 0;
choutin 0:df2659fd8031 24
choutin 0:df2659fd8031 25 int hub2x = 900;
choutin 0:df2659fd8031 26 int hub2y = 0;
choutin 0:df2659fd8031 27
choutin 0:df2659fd8031 28
choutin 0:df2659fd8031 29 int goalx = 0, goaly = blue()*1200;//受け渡しゾーンの中心
choutin 0:df2659fd8031 30 //定義終了
choutin 0:df2659fd8031 31
choutin 0:df2659fd8031 32 int retry=0;
choutin 0:df2659fd8031 33
choutin 0:df2659fd8031 34
choutin 0:df2659fd8031 35 //ここでretryに数値を代入
choutin 0:df2659fd8031 36
choutin 0:df2659fd8031 37 switch(retry){
choutin 0:df2659fd8031 38 case 0:
choutin 0:df2659fd8031 39 open_hand();
choutin 0:df2659fd8031 40 moveto(hub1x, hub1y);
choutin 0:df2659fd8031 41
choutin 0:df2659fd8031 42 moveto(targetx[0], targety[0]);
choutin 0:df2659fd8031 43 close_hand();
choutin 0:df2659fd8031 44 lift(1);
choutin 0:df2659fd8031 45
choutin 0:df2659fd8031 46 case 1:
choutin 0:df2659fd8031 47 open_hand();
choutin 0:df2659fd8031 48 moveto(targetx[1], targety[1]);
choutin 0:df2659fd8031 49 close_hand();
choutin 0:df2659fd8031 50 lift(1);
choutin 0:df2659fd8031 51
choutin 0:df2659fd8031 52 case 2:
choutin 0:df2659fd8031 53 open_hand();
choutin 0:df2659fd8031 54 moveto(targetx[2], targety[2]);
choutin 0:df2659fd8031 55 close_hand();
choutin 0:df2659fd8031 56
choutin 0:df2659fd8031 57 moveto(goalx,goaly);
choutin 0:df2659fd8031 58 open_arm();
choutin 0:df2659fd8031 59 release();
choutin 0:df2659fd8031 60 back();
choutin 0:df2659fd8031 61 //3つリリースした
choutin 0:df2659fd8031 62 case 3:
choutin 0:df2659fd8031 63 open_arm();
choutin 0:df2659fd8031 64 open_hand();
choutin 0:df2659fd8031 65 moveto(targetx[3], targety[3]);
choutin 0:df2659fd8031 66 close_arm();
choutin 0:df2659fd8031 67 close_hand();
choutin 0:df2659fd8031 68 lift(2);
choutin 0:df2659fd8031 69
choutin 0:df2659fd8031 70 case 4:
choutin 0:df2659fd8031 71 open_hand();
choutin 0:df2659fd8031 72 moveto(targetx[4], targety[4]);
choutin 0:df2659fd8031 73 close_hand();
choutin 0:df2659fd8031 74
choutin 0:df2659fd8031 75 moveto(goalx,goaly);
choutin 0:df2659fd8031 76 open_arm();
choutin 0:df2659fd8031 77 release();
choutin 0:df2659fd8031 78 back();
choutin 0:df2659fd8031 79 //3つリリースした
choutin 0:df2659fd8031 80
choutin 0:df2659fd8031 81 case 5:
choutin 0:df2659fd8031 82 moveto(targetx[3], targety[3]);//ハブとして利用
choutin 0:df2659fd8031 83
choutin 0:df2659fd8031 84 open_arm();
choutin 0:df2659fd8031 85 open_hand();
choutin 0:df2659fd8031 86 moveto(targetx[5], targety[5]);
choutin 0:df2659fd8031 87
choutin 0:df2659fd8031 88 close_arm();
choutin 0:df2659fd8031 89 close_hand();
choutin 0:df2659fd8031 90 lift(2);
choutin 0:df2659fd8031 91
choutin 0:df2659fd8031 92 case 6:
choutin 0:df2659fd8031 93 open_hand();
choutin 0:df2659fd8031 94 moveto(targetx[6], targety[6]);
choutin 0:df2659fd8031 95 close_hand();
choutin 0:df2659fd8031 96
choutin 0:df2659fd8031 97
choutin 0:df2659fd8031 98 moveto(goalx,goaly);
choutin 0:df2659fd8031 99 open_arm();
choutin 0:df2659fd8031 100 release();
choutin 0:df2659fd8031 101
choutin 0:df2659fd8031 102 back();
choutin 0:df2659fd8031 103
choutin 0:df2659fd8031 104 case 7:
choutin 0:df2659fd8031 105 moveto(targetx[3], targety[3]);//ハブとして利用
choutin 0:df2659fd8031 106
choutin 0:df2659fd8031 107 open_arm();
choutin 0:df2659fd8031 108 open_hand();
choutin 0:df2659fd8031 109 moveto(targetx[7], targety[7]);
choutin 0:df2659fd8031 110 close_hand();
choutin 0:df2659fd8031 111 lift(2);
choutin 0:df2659fd8031 112
choutin 0:df2659fd8031 113 moveto(hub2x, hub2y);
choutin 0:df2659fd8031 114
choutin 0:df2659fd8031 115 case 8:
choutin 0:df2659fd8031 116 open_hand();
choutin 0:df2659fd8031 117 moveto(targetx[8], targety[8]);
choutin 0:df2659fd8031 118 close_hand();
choutin 0:df2659fd8031 119
choutin 0:df2659fd8031 120
choutin 0:df2659fd8031 121 moveto(goalx,goaly);
choutin 0:df2659fd8031 122 open_arm();
choutin 0:df2659fd8031 123
choutin 0:df2659fd8031 124 back();
choutin 0:df2659fd8031 125
choutin 0:df2659fd8031 126 moveto(1800,blue()*1200);//invade
choutin 0:df2659fd8031 127
choutin 0:df2659fd8031 128 return 0;//終了
choutin 0:df2659fd8031 129 }
choutin 0:df2659fd8031 130 }