//行動のセット
public void objectMoveSet(GameData gData) {
int xrange=0;
int yrange=0;
int gomove=0;
int rand=0;
int[] pxy=gData.pPlatform.getxy();
xrange=pxy[0]-(int)x;
yrange=pxy[1]-(int)y;
int halfWidth=gra.getWidth()/6; //グラのWidthは3アニメ分の幅なので、/2ではなく/6
int halfHeight=gra.getHeight()/8; //同じくHeightは上下左右の4アニメ分なので、/8
if (moveType==1) { //プレイヤーに近づいてくるパターン。 //1.最至近のターゲットを計算する。 rand=gData.randMake(10); //rand=2; //5割は何もしない if (rand>=5 && rand <=7) { int rand2=gData.randMake(4); if (rand2==1) gomove=ymove(yrange,halfHeight); if (rand2==2) gomove=ymove(yrange,halfHeight); if (rand2==3) gomove=xmove(xrange,halfWidth); if (rand2==4) gomove=xmove(xrange,halfWidth); } if (rand>=7 && rand<=8) { if (Math.abs(yrange)<=halfHeight) { gomove=xmove(xrange,halfWidth); } else { gomove=ymove(yrange,halfHeight); } } if (rand>=9) { if (Math.abs(xrange)<=halfWidth) {
gomove=ymove(yrange,halfHeight); } else { gomove=xmove(xrange,halfWidth); } }
}
//移動方向が決まったら変数に移動データを入力する。
switch (gomove) { case 2: frictionY=1; vy+=ACCELERATION; break; case 8: frictionY=1; vy+=-ACCELERATION; break; case 6: frictionX=1; vx+=ACCELERATION; break; case 4: frictionX=1; vx+=-ACCELERATION; break;
}
if (gomove!=0 && shift!=gomove) shift=gomove;