PlainCharに戻る PlainChar.crashToLine - オブジェクトと線分の衝突判定を行います。 書式crashToLine(sx,sy,dx,dy,width,xx,yy)
戻り値(sx,sy)と(dx,dy)を結ぶ、幅がwidthドットの線分と点(xx,yy)がぶつかっていれば 真(0でない値)。そうでなければ偽 (0) ※ (sx,sy)と(dx,dy) が一致してしまうとエラーになります 例1//------LineRoll.tonyu----- extends SpriteChar; a=0; while (1) { sx=x+cos(a)*100; sy=y+sin(a)*100; drawLine(x,y,sx,sy,$clWhite); update(); a+=rnd(10); } //--end of LineRoll.tonyu----- //---- Jiki.tonyu----- extends SpriteChar; while(1) { if (getkey(39)>0) x+=3; if (getkey(37)>0) x-=3; if (getkey(40)>0) y+=3; if (getkey(38)>0) y-=3; if (crashToLine($LineRoll.x,$LineRoll.y,$LineRoll.sx,$LineRoll.sy,10)) { die(); } update(); } //---- end of Jiki.tonyu----- |