extends SpriteChar; p=$pat_shell+0; noHit=0; vx=5; // 進行方向 jmp=0; a=newAnimation(); // AnimationAdapterを作成 a.loop($pat_shellred+0,$pat_shellred+3,3);// 敵の2つのパターンを往復するアニメーション while (1) { if (getkey(37)>1) x-=vx; if (getkey(39)>1) x+=vx; if ($map.getAt(x+10,y)==$pat_Block+1 || $map.getAt(x+10,y)==$pat_Block+3 ) { // 進行方向のマップパターンを調べ、ブロックのパターンだったら vx=-vx; // 進行方向を反転する } if (vx<0) f=1; else f=0; // vx が負(左向き)なら反転 y+=vy; // vy: y 方向の速度。 yにvy を加える if($map.getAt(x,y+10)==$pat_block+0){ y+=2; }else{ if (getkey(32)) vy=-7; // スペースキーを押したらジャンプ } update(); }