This blog is under construction

Friday 6 September 2013

Animate waves using C graphics

Waves animation using C graphics


  #include <stdio.h>
  #include <conio.h>
  #include <graphics.h>
  #include <dos.h>

  int main() {
        /* request auto detection */
        int gdriver = DETECT, gmode;
        int err, radius = 5, k = 0;

        /* initialize graphic mode */
        initgraph(&gdriver, &gmode, "C:/TURBOC3/BGI");
        err = graphresult();

        if (err != grOk) {
                /* error occurred */
                printf("Graphic Error: %s\n",
                                grapherrormsg(err));
                return 0;
        }

        while (k <= 90) {
                /* creating waves using arcs with specific angles */
                arc(0, 0, 270, 360, radius);
                arc(getmaxx(), 0, 180, 270, radius);
                arc(0, getmaxy(), 0, 90, radius);
                arc(getmaxx(), getmaxy(), 90, 180, radius);
                radius = radius + 5;
                delay(50);
                k++;
        }

        getch();
        /* deallocate memory allocated for graphic screen */
        closegraph();
        return 0;
  }




Output: (Animate waves using C graphics)


No comments:

Post a Comment