动来动去 发表于 2007-7-2 12:52

[求助] 实心小球沿正弦曲线运动

要求画出一个实心小球,并让小球沿着正弦曲线运动.[em06][em06]<BR>我还不太会用图形函数 希望 大家能帮帮我

cdmalcl 发表于 2007-7-3 21:40

[em05][em02]

动来动去 发表于 2007-7-3 21:56

<P>[em02]</P>

动来动去 发表于 2007-7-3 21:58

<P>[em10]谢谢~ 其实不想谢你!![em26]</P>

cdmalcl 发表于 2007-7-3 22:14

<P>不用谢 不用谢 多请我几顿饭就行[em02]</P>

动来动去 发表于 2007-7-3 22:17

<P>我看这个机会还是留给别人吧~~[em09]</P>

cdmalcl 发表于 2007-7-4 00:47

随意随意 能有饭吃就行[em02]

动来动去 发表于 2007-7-4 12:39

[em05]那你就等等吧`

cdmalcl 发表于 2007-7-4 17:55

<P>晕了<BR>另一个程序我怎么也粘贴不上来<BR><BR>你上QQ了管我要吧</P>





cdmalcl 发表于 2007-7-5 08:38

<P>还是把程序贴出来吧 要不 苍穹大哥会怒的[em02]<BR><BR><BR>#include &lt;graphics.h&gt;<BR>#include &lt;math.h&gt;<BR>#include &lt;stdlib.h&gt;</P>
<P>#define PI  3.14<BR>#define LINECOLOR   7<BR>#define ESC 283</P>
<P>typedef struct<BR>{<BR>    int x ;<BR>    int y ;<BR>}SITE;</P>
<P>typedef struct<BR>{<BR>    SITE s0 ;<BR>    SITE s1 ;<BR>    SITE s2 ;<BR>    SITE s3 ;<BR>}RECTSITE;</P>
<P>int Init() ;<BR>int drawProcess() ;<BR>int moveRectangle(RECTSITE rectSite) ;<BR>int End() ;</P>
<P>int screenMaxx2, screenMaxy2 ;</P>
<P>main()<BR>{<BR>    Init();<BR>    drawProcess();<BR>    End();<BR>}</P>
<P>int Init()<BR>{<BR>    int gd = DETECT, gm = 0 ;</P>
<P>    initgraph(&amp;gd, &amp;gm, "") ;</P>
<P>    screenMaxx2 = getmaxx()/2 ;<BR>    screenMaxy2 = getmaxy()/2 ;</P>
<P>}<BR>/*<BR>        Len0<BR>    s0-------s1<BR>    |        |<BR>    |        |Len1<BR>    |        |<BR>    |        |<BR>    s3-------s2</P>
<P>*/<BR>int drawProcess()<BR>{<BR>    RECTSITE rectSite ;<BR>    int moveCenterX, moveCenterY ;<BR>    int i ;<BR>    float LenR, Len0, Len1 ;<BR>    float startr, r ;</P>
<P>    Len0 = 50 ;<BR>    Len1 = 80 ;<BR>    LenR = sqrt(Len0*Len0+Len1*Len1) ;<BR>    startr = atan(Len1/Len0) ;</P>
<P>    moveCenterX = screenMaxx2 ;<BR>    moveCenterY = screenMaxy2 ;</P>
<P>    rectSite.s0.x = moveCenterX ;<BR>    rectSite.s0.y = moveCenterY ;</P>
<P>    while(!kbhit())<BR>    {<BR>        for(r = 0;r &lt;= PI*2;r+=0.0314)<BR>        {<BR>            rectSite.s1.x = Len0*sin(r)+moveCenterX ;<BR>            rectSite.s2.x = LenR*sin(r-startr)+moveCenterX ;<BR>            rectSite.s3.x = Len1*sin(r-PI/2)+moveCenterX ;<BR>            rectSite.s1.y = Len0*cos(r)+moveCenterY ;<BR>            rectSite.s2.y = LenR*cos(r-startr)+moveCenterY ;<BR>            rectSite.s3.y = Len1*cos(r-PI/2)+moveCenterY ;</P>
<P>            setcolor(LINECOLOR) ;<BR>            moveRectangle(rectSite) ;</P>
<P>            delay(1000) ;</P>
<P>            setcolor(0) ;<BR>            moveRectangle(rectSite) ;</P>
<P>            if(kbhit())<BR>            {<BR>                if(bioskey(0) == ESC)<BR>                 return 0 ;<BR>            }<BR>        }</P>
<P>    }<BR>}</P>
<P>int moveRectangle(RECTSITE rectSite)<BR>{<BR>    line(rectSite.s0.x, rectSite.s0.y, rectSite.s1.x, rectSite.s1.y) ;<BR>    line(rectSite.s1.x, rectSite.s1.y, rectSite.s2.x, rectSite.s2.y) ;<BR>    line(rectSite.s2.x, rectSite.s2.y, rectSite.s3.x, rectSite.s3.y) ;<BR>    line(rectSite.s3.x, rectSite.s3.y, rectSite.s0.x, rectSite.s0.y) ;</P>
<P>}</P>
<P>int End()<BR>{<BR>    setcolor(4) ;<BR>    outtextxy(screenMaxx2, screenMaxy2, "END!") ;<BR>    getch() ;<BR>    closegraph() ;<BR>}</P>

页: [1]

编程论坛