¥Í¥Ã¥È¾å¤Ë»²¹Í¤Ë¤Ê¤ê¤½¤¦¤Êʸ¸¥¤¬¤¢¤Ã¤¿¤Î¤Ç¤¢¤²
http://hikari-hinomoto.hp.infoseek.co.jp/PDF/DX7A02.pdf
ÀµÊý·ÁƱ»Î¤ÎÅö¤¿¤êȽÄê¤Ê¤é¡¢NO.18049¤Î¡¤ÎÊýË¡¤Ç
¡¡tekix : Ũ¤ÎºÂɸX
¡¡tekiy : Ũ¤ÎºÂɸY
¡¡s : Ũ¤Î¥µ¥¤¥º¡Ü¸«Êý¤Î¥µ¥¤¥º
¡¡if ((tekix-mousex)/s | (tekiy-mousey)/s) == 0
¤È¤¹¤ë¤È¡¢HSP¤Ç¤Ï®¤¯È½Äê¤Ç¤ë¡¥
tekix = ginfo_winx >> 1 ; Ũ¤ÎºÂɸ
tekiy = ginfo_winy >> 1 ;
tekis = 20 ; Ũ¤Î¥µ¥¤¥º
mikatas = 30 ; ¸«Êý¤Î¥µ¥¤¥º
s = tekis + mikatas
*main
if( ((tekix-mousex)/s | (tekiy-mousey)/s) == 0 ) {
dialog "hit"
}
redraw 0
color 255, 255, 255 : boxf : color
boxf tekix-tekis, tekiy-tekis, tekix+tekis, tekiy+tekis
boxf mousex-mikatas, mousey-mikatas, mousex+mikatas, mousey+mikatas
redraw
await 10
goto *main
¤½¤ì¤«¤é¡¢²¿¤«¤ÎÌò¤ËΩ¤Ä¤È»×¤¤¡¢¶ë·Á¤ÈÅÀ¤ÎÅö¤¿¤êȽÃǤò¤¹¤ë´Ø¿ô¤òºî¤Ã¤Æ¤ß¤¿¡¥
/*
|¡Ú¤¢¤ëÅÀ¤¬¶ë·Á¾å¤Ë¤¢¤ë¤«Ä´¤Ù¤ë¡Û
| onsquare array rect_x, array rect_y, int mx, int my
| rect_x : ¶ë·Á¤ÎĺÅÀ¤¬ÂåÆþ¤µ¤ì¤¿ÇÛÎóÊÑ¿ô (X ºÂɸ)
| rect_y : ¶ë·Á¤ÎĺÅÀ¤¬ÂåÆþ¤µ¤ì¤¿ÇÛÎóÊÑ¿ô (Y ºÂɸ)
| ÇÛÎó¤Ï¡¢º¸¾å(0),±¦¾å(1),±¦²¼(2),º¸²¼(3)¤Î½çÈÖ
| mx : Ä´¤Ù¤ëÅÀ (X ºÂɸ)
| my : Ä´¤Ù¤ëÅÀ (Y ºÂɸ)
|¡ÚÌá¤êÃÍ¡Û
| 0 : (mx, my)¤¬¶ë·Á¾å¤Ë¤Ê¤¤
| 1 : (mx, my)¤¬¶ë·Á¾å¤Ë¤¢¤ë
*/
#module
#defcfunc onsquare array rect_x, array rect_y, int mx, int my
x1 = mx - rect_x(0)
y2 = my - rect_y(3)
x2 = rect_x(3) - mx
y1 = rect_y(0) - my
flg = 1
repeat 2, 1
a = rect_x(cnt) - rect_x(0)
b = rect_y(cnt) - rect_y(0)
// Àþʬ¤ÈÀþʬ¤Î½Å¤Ê¤ê¤òÄ´¤Ù¤ë
if( (a*y1+b*x1 ^ a*y2+b*x2) >> 31 ) {
flg--
break
}
loop
return flg
#global
¥µ¥ó¥×¥ë¡§
CX = ginfo_winx >> 1 ; Ãæ¿´
CY = ginfo_winy >> 1 ;
PI = 3.1415926535897932384627
bsx = 300 ; ¶ë·Á¤ÎÉý
bsy = 150 ; ¶ë·Á¤Î¹â¤µ
ang = 0.0
x = -bsx/2, bsx/2, -bsx/2, bsx/2
y = -bsy/2, -bsy/2, bsy/2, bsy/2
*main
ang += 0.005
// ¶ë·Á¡§4¤Ä¤ÎĺÅÀ¤ÎºÂɸ¤òÂåÆþ¤¹¤ë
repeat 4
rect_x(cnt) = CX + cos(ang)*x(cnt) - sin(ang)*y(cnt)
rect_y(cnt) = CY + cos(ang)*y(cnt) + sin(ang)*x(cnt)
loop
// ¥Ò¥Ã¥È¥Á¥§¥Ã¥¯
if( onsquare(rect_x, rect_y, mousex, mousey) ) {
title "hit"
} else : title ""
redraw 0
color 255, 255, 255 : boxf
color
grect CX, CY, ang, bsx, bsy
redraw
await 10
goto *main
¶ë·Á¤ÈÅÀ¤ÎÅö¤¿¤êȽÃǤò¤¹¤ë¥¢¥ë¥´¥ê¥º¥à¤Ï¼¡¤Î¤è¤¦¡¥
¡¡¶ë·Á¤ò¹½À®¤¹¤ëÀþʬ¤ÎÂоÝÀ¤òÍøÍѤ·
¡¡¡¡(mx, my) : ¥Þ¥¦¥¹¤ÎºÂɸ
¡¡¡¡(gx, gy) : ¶ë·Á¤Î½Å¿´
¡¡¡¡(sx, sy) : (gx, gy) ¤òÃæÅÀ¤È¤·¤¿ (mx, my) ¤ÎÂоÎÅÀ
¡¡¤È¤·¤Æ¡¢¶ë·Á¾å¤ÎÀþʬ¤¬(sx, sy)¡¢(mx, my)Æâ¤Ë¤¢¤ë¤«Ä´¤Ù¤ë¡¥
¡¡¤³¤ì¤Ï2ËܤÎÀþʬ¤Ë¤Ä¤¤¤ÆÄ´¤Ù¤ë¤À¤±¤Ç¤è¤¤¡¥
¤³¤ì¤ò²ò¤¤¤Æ¡¢¼°ÊÑ·Á¤ò¤·¤Æ¤¤¤¯¤È¤«¤Ê¤ê´Êά²½¤Ç¤¤ë¡¥