double idou_boss_x(double x_player,double x_boss) { double w=x_player-x_boss; static int ax_boss,ridatsu_t; static BOOL hidari,migi; if(w>-100 && w<=0){ //プレイヤー機が左至近距離にいる if(hidari==FALSE){ //(ボス機はプレイヤー機の)左側から移動して来ていない if(ridatsu_t<20){ //時間内に反対側へ離脱せよ migi=TRUE; //左側から移動して来ていないならボス機が右側にいる状態でプレイヤー機が左至近距離に入った事になる ax_boss-=500; //反対側へ移動せよ 反対側への移動を試みる }else //ridatsu_t>=20 時間切れ 諦めて元の方向へ移動せよ ax_boss+=1000; //離れるときは加速度アップ ・・・が、反対側にさえ行けなかった }else{ //hidari==TRUE (ボス機はプレイヤー機の)左側から移動して来た if(ridatsu_t<20) ax_boss+=1000; //離れるときは加速度アップ とりあえず反対側へ移動できた else ax_boss-=500; //時間切れ 諦めて元の方向へ移動せよ ・・・が、離れられなかった } ridatsu_t=(ridatsu_t+1)%40; //プレイヤー機が至近距離にいる時間で動作を変える 下のタイマーと連動 }else if(w>0 && w<=100){ //プレイヤー機が右至近距離にいる if(migi==FALSE){ //(ボス機はプレイヤー機の)右側から移動して来ていない if(ridatsu_t<20){ hidari=TRUE; //右側から移動して来ていないならボス機が左側にいる状態でプレイヤー機が右至近距離に入った事になる ax_boss+=500; }else //ridatsu_t>=20 ax_boss-=1000; }else{ //migi==TRUE (ボス機はプレイヤー機の)右側から移動して来た if(ridatsu_t<20) ax_boss-=1000; else ax_boss+=500; } ridatsu_t=(ridatsu_t+1)%40; //上のタイマーと連動 同時動作はあり得ない 0〜39 }else if(w>-400 && w<=-100){ //プレイヤー機が左中距離にいる ボス機が右 右に離れろ hidari=FALSE; //(ボス機はプレイヤー機の)左側から移動して来て十分離れた ridatsu_t=0; //十分離れたからタイマーを元に戻しておく ax_boss+=500; }else if(w<=-400) //プレイヤー機が左遠距離にいる ボス機が右 左に近づけ ax_boss-=500; else if(w>100 && w<=400){ //プレイヤー機が右中距離にいる ボス機が左 左に離れろ migi=FALSE; //(ボス機はプレイヤー機の)右側から移動して来て十分離れた ridatsu_t=0; //十分離れたからタイマーを元に戻しておく ax_boss-=500; }else if(w>400) //プレイヤー機が右遠距離にいる ボス機が左 右に近づけ ax_boss+=500; if(x_boss>=window.right-100) //ウィンドウの右端を超えた ax_boss-=1000; //強制力(空気抵抗)により押し戻される else if(x_boss<100) //ウィンドウの左端を越えた ax_boss+=1000; if(migi==TRUE || hidari==TRUE){ //プレイヤー機が至近距離にいるなら緊急離脱 最高加速度アップ if(ax_boss>10000) ax_boss=10000; else if(ax_boss<-10000) ax_boss=-10000; }else{ if(ax_boss>7500) //緊急離脱からの減速処理 距離100〜400での最高加速度 ax_boss=7500; else if(ax_boss<-7500) ax_boss=-7500; else if(ax_boss>5000) //通常最高加速度 ax_boss=5000; else if(ax_boss<-5000) ax_boss=-5000; } aax_boss=ax_boss; //for Debug return (double)1/2*ax_boss*timer_s*timer_s; //相対移動量を返す } double idou_boss_y(double x_player,double y_player,double x_boss,double y_boss) { double w=x_player-x_boss,h=y_player-y_boss; static int ay_boss; if(w>-100 && w<100 && h>-100 && h<100){ //プレイヤー機が至近距離にいる if(h<0) //ボス機が下 近すぎるから下に離れろ ay_boss+=500; else //ボス機が上 近すぎるから上に離れろ ay_boss-=500; }else{ //通常時 プレイヤー機とy座標を合わせようとする if(h<0) //ボス機が下 上に近づけ ay_boss-=500; else //ボス機が上 下に近づけ ay_boss+=500; } if(y_boss>=window.bottom) ay_boss-=1000; else if(y_boss<0) ay_boss+=1000; if(ay_boss>5000) ay_boss=5000; else if(ay_boss<-5000) ay_boss=-5000; aay_boss=ay_boss; //for Debug return (double)1/2*ay_boss*timer_s*timer_s; //相対移動量を返す } double idou_player_x(double x_player,double x_boss,BOOL mahi) { static int ax_player; BOOL sousa=FALSE; if(GetKeyState('S')>=0 && mahi==FALSE){ //自己修復中じゃない 麻痺状態じゃない if(GetKeyState(VK_LEFT)<0){ if(GetKeyState('A')<0 && x_player>=0) ax_player-=2000; //加速度アップ else ax_player-=1000; //通常加速度 ウィンドウ外部では加速度アップ無効 sousa=TRUE; //操作した }else if(GetKeyState(VK_RIGHT)<0){ if(GetKeyState('A')<0 && x_player=window.right) //ウィンドウ右端を超えた 大きな空気抵抗 ax_player-=2000; else if(x_player<0) //ウィンドウ左端を越えた ax_player+=2000; else if(sousa==FALSE){ //ウィンドウ内部 操作していない場合は空気抵抗発生 if(ax_player>0) ax_player-=500; else if(ax_player<0) ax_player+=500; } if(ax_player<-max_speed) //上限加速度を超えた ax_player=-max_speed; else if(ax_player>max_speed) ax_player=max_speed; aax_player=ax_player; //for Debug return (double)1/2*ax_player*timer_s*timer_s; //相対移動量を返す } double idou_player_y(double y_player,double y_boss,BOOL mahi) { static int ay_player; BOOL sousa=FALSE; if(GetKeyState('S')>=0 && mahi==FALSE){ if(GetKeyState(VK_UP)<0){ if(GetKeyState('A')<0 && y_player>=0) ay_player-=2000; else ay_player-=1000; sousa=TRUE; }else if(GetKeyState(VK_DOWN)<0){ if(GetKeyState('A')<0 && y_player=window.bottom) ay_player-=2000; else if(y_player<0) ay_player+=2000; else if(sousa==FALSE){ if(ay_player>0) ay_player-=500; else if(ay_player<0) ay_player+=500; } if(ay_player<-max_speed) ay_player=-max_speed; else if(ay_player>max_speed) ay_player=max_speed; aay_player=ay_player; //for Debug return (double)1/2*ay_player*timer_s*timer_s; //相対移動量を返す }