IRiS nX
114 ARTICLES / 235 REPLIES [1:2]
=ADMIN=


#128. µ¨ÆÄÀÌ°ÔÀÓÁ¦ÀÛÃʺ¸
ij¸¯¿òÁ÷ÀÌ´Â°É ¸¸µé¾îº¸·Á°íÇÕ´Ï´Ù. 2005/08/06 (Sat)

¹æÇâÅ°·Î ÁÂ,¿ì,»ó,ÇÏ ¶Ç´Â Á»ó,¿ì»ó,ÁÂÇÏ,¿ìÇÏ ¹æÇâÀ¸·Î
¿òÁ÷ÀÌ´Â °ÍÀº ½¬¿ö¼­ ¸¸µé±ä Çߴµ¥

À̹ø¿£ ¸¶¿ì½º·Î È­¸éÁÂÇ¥(0,0)À» Ŭ¸¯Çϸé
È­¸éÁÂÇ¥(1024,768)¿¡ À§Ä¡ÇÑ Ä³¸¯ÅÍ°¡
¼­¼­È÷ È­¸éÁÂÇ¥(0,0)À¸·Î À̵¿Çϴ°ÍÀ» ¸¸µé¾îº¸°í ½Í½À´Ï´Ù.
- ¹æÇâÅ°·Î ¿òÁ÷À̴°ÍÀ» ¸¸µé°í³­µÚ ¸¶¿ì½º·Î À§Ä¡ Ŭ¸¯Çϸé
ÇØ´çÀ§Ä¡±îÁö ¿òÁ÷À̴°͵µ ¸¸µé±äÇߴµ¥ ÀÏÁ¤ÇÏ°Ô ¿òÁ÷ÀÌÁö°¡ ¾Ê´õ¶ó±¸¿ä.
ij¸¯ÅÍ À§Ä¡¿Í Ŭ¸¯ÇÑ°÷ÀÇ À§Ä¡... È­¸é»óÀÇ °Å¸®°è»êÀ» ¾îÂîÇؾßÇÒÂî ¤Ñ¤Ñ;
°í¼ö´ÔÀÇ °¡¸£Ä§Á» ¹Þ°í½Í½À´Ï´Ù. ±×·³ ÁÁÀºÁÖ¸»µÇ½Ã±æ ¹Ù¶ó¸ç...^^

#128-1. ¾È¿µ±â 2005/08/09 (Tue)
...
Æû¿¡ ŸÀÌ¸Ó Çϳª ¿Ã¸®½Ã°í ¾Æ·¡ ¼Ò½º¿¡ ³ª¿Í ÀÖ´Â 3°³ÀÇ À̺¥Æ®¸¦ ¿¬°áÇϼ¼¿ä.
±×¸®°í Æû¿¡´Ù°¡ ¸¶¿ì½º Ŭ¸¯À» ÇÏ¸é »¡°£Á¡ÀÌ ±× À§Ä¡·Î µî¼Óµµ ¿îµ¿À» ÇÕ´Ï´Ù.

À̵¿ °£°ÝÀº 10-pixel ´ÜÀ§·Î 10msÀÔ´Ï´Ù. °ªÀº Á¶Á¤ÇÏ½Ã¸é µË´Ï´Ù.

¼Ò½º ³»¿ëÀº º°°Å ¾Æ´Ï°í °íµîÇб³ ¼öÇÐÀÇ »ï°¢ÇÔ¼ö¿Í º¤ÅÍÀÔ´Ï´Ù.
»ï°¢ÇÔ¼ö·Î À̵¿ÇÒ °¢µµ¿Í ´ÜÀ§º¤Å͸¦ ±¸ÇÑ ÈÄ ±× ´ÜÀ§º¤ÅÍ¿¡ À̵¿ ¼Óµµ¸¦ °öÇÏ¿© Á¤ÇØÁø ½Ã°£¿¡ ¸Â°Ô ¹éÅÍ ÇÕÀ» ¿¬»êÇϸ鼭 À̵¿ÇÕ´Ï´Ù.

ÀÌ°ÍÀº »ùÇÃÀÔ´Ï´Ù.

implementation

{$R *.DFM}

uses
math;

type
TVector = record
x, y: double;
end;
const
MOVE_STEP = 10;
QAZ = MOVE_STEP div 2;
var
g_pos: TVector = (x: 30; y:30);
g_dest: TVector;
g_vector: TVector;

procedure TForm1.FormCreate(Sender: TObject);
begin
Canvas.Brush.Color := clRed;
Timer1.Interval := 10;
Timer1.Enabled := FALSE;
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
angle: double;
begin
angle := arctan2(y - g_pos.y, x - g_pos.x);
g_dest.x := x;
g_dest.y := y;
g_vector.x := MOVE_STEP * cos(angle);
g_vector.y := MOVE_STEP * sin(angle);
timer1.Enabled := TRUE;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
g_pos.x := g_pos.x + g_vector.x;
g_pos.y := g_pos.y + g_vector.y;
if (abs(g_pos.x - g_dest.x) < QAZ) and (abs(g_pos.y - g_dest.y) < QAZ) then begin
g_pos := g_dest;
Timer1.Enabled := FALSE;
end;
Canvas.FillRect(Bounds(round(g_pos.x)-1, round(g_pos.y)-1, 3, 3));
end;


NAME / EMAIL
URL
SUBJECT
MESSAGE
ATTACH
ATTACH STYLE COOKIE  
[PREV] [NEXT] return


IRiS nX by NvyU =starry scape=