Computer Graphics Mini Project

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Introduction to Animation

Animation is the process of designing, drawing, making layouts and


preparation of photographic sequences which are integrated in the multimedia
and gaming products. Animation involves the exploitation and management of
still images to generate the illusion of movement. A person who creates
animations is called animator. He / she use various computer technologies to
capture the still images and then to animate these in desired sequence.

Multimedia is the term used to represent combination of visual and audio


materials gathered from various resources and then added into one single
combination. A multimedia product can be sets of texts, graphic arts, sounds,
animations and videos. Precisely, term multimedia is used to refer visual and
audio materials into a single common presentation which can be played in a
computer including CD ROM or digital video, internet or web technology,
streaming audio or video and data projection system etc.

Modern entertainment industry i.e. film and television has gained new heights
because of advances in animation, graphics and multimedia. Television
advertisements, cartoons serials, presentation and model designs - all use
animation and multimedia techniques.

Problem Statement: -

To make a short animation of a man sailing on a boat in a river while raining


using C language in Turbo C++ IDE.
Code: -

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

int main()
{
    int gdriver = DETECT, gmode, err;
    int i = 0, j, x, y, x1, y1, x2, y2;

    initgraph(&gdriver, &gmode, "C:\\TURBOC3\\BGI");


    err = graphresult();

    if (err != grOk)
  {
        printf("Graphics Error: %s\n",
               grapherrormsg(err));
        return 0;
  }

    j = 0;

    /* initialize position for boat */


    x = 50, y = getmaxy() / 2 + 140;

    while (x + 60 < getmaxx() && (!kbhit()))


  {
        /* setting positions for rain */
        x1 = 10, i = y1 = 0;
        x2 = 0, y2 = 50;

        /* clears graphic screen */


        cleardevice();

        /* setting the color of the river/sea */


        setcolor(LIGHTBLUE);
        setlinestyle(SOLID_LINE, 1, 1);
        setfillstyle(SOLID_FILL, LIGHTBLUE);

        /* draw the river/sea */


        rectangle(0, getmaxy() / 2 + 150, getmaxx(), getmaxy());
        floodfill(getmaxx() - 10, getmaxy() - 10, LIGHTBLUE);

        /* rain drops */
        setlinestyle(DASHED_LINE, 1, 2);
        while (i < 700)
    {
            line(x1, y1, x2, y2);
            x1 = x1 + 20;
            y2 = y2 + 50;
            i++;
    }

        /* drawing the boat */


        setlinestyle(SOLID_LINE, 1, 2);
        setcolor(BROWN);
        setfillstyle(SOLID_FILL, BROWN);
        sector(x, y, 180, 360, 50, 10);

        setcolor(DARKGRAY);
        setlinestyle(SOLID_LINE, 1, 3);

        /* leg and body of stick man */


        line(x + 40, y - 15, x + 40, y - 40);
        line(x + 40, y - 15, x + 45, y - 10);
        line(x + 45, y - 10, x + 45, y);
        line(x + 40, y - 15, x + 37, y);

        /* head and hand of stick man */


        circle(x + 40, y - 45, 5);
        line(x + 40, y - 35, x + 50, y - 30);
        line(x + 40, y - 35, x + 35, y - 32);
        line(x + 35, y - 32, x + 45, y - 25);
        line(x + 60, y - 45, x + 27, y + 10);

        /* moving the position of boat and stick man */


        x++;

        setcolor(LIGHTBLUE);
        delay(250);

        /* clears the graphic device */


        cleardevice();

        /* drawing sea/river */
        setlinestyle(SOLID_LINE, 1, 1);
        setfillstyle(SOLID_FILL, LIGHTBLUE);
        rectangle(0, getmaxy() / 2 + 150, getmaxx(), getmaxy());
        floodfill(getmaxx() - 10, getmaxy() - 10, LIGHTBLUE);

        /* rain drops */
        setlinestyle(DASHED_LINE, 1, 2);
        x1 = 10, i = y1 = 0;
        x2 = 0, y2 = 70;

        while (i < 700)


    {
            line(x1, y1, x2, y2);
            x1 = x1 + 30;
            y2 = y2 + 60;
            i++;
    }

        /* drawing boat */
        setlinestyle(SOLID_LINE, 1, 1);
        setcolor(BROWN);
        setfillstyle(SOLID_FILL, BROWN);
        sector(x, y, 180, 360, 50, 10);

        /* body and leg of stic man */


        setcolor(DARKGRAY);
        setlinestyle(SOLID_LINE, 1, 3);
        line(x + 40, y - 15, x + 40, y - 40);
        line(x + 40, y - 15, x + 45, y - 10);
        line(x + 45, y - 10, x + 45, y);
        line(x + 40, y - 15, x + 37, y);

        /* head, hands of stick man */


        circle(x + 40, y - 45, 5);
        line(x + 40, y - 35, x + 52, y - 30);
        line(x + 40, y - 35, x + 37, y - 32);
        line(x + 37, y - 32, x + 49, y - 25);
        line(x + 60, y - 45, x + 27, y + 10);

        /* forwarding the position of the boat */


        x++;

        /* sleep for 250 milliseconds */


        delay(100);

        /* clears the graphic device */


        cleardevice();
        j++;
  }

    getch();

    /* deallocate memory allocated for graphic screen */


    closegraph();
    return 0;
}
Output: -

You might also like