A Simple Animation of a Road

On August 18, 2015, in Animation, by , Views : 6161


A very simple program to show an animated road.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
 
void main()
{
        int i,gd=DETECT,gm;
        detectgraph(&gd,&gm);
        initgraph(&gd,&gm,"*** BGI Path ***");
 
        // Set Background colour to GREEN
        setbkcolor(GREEN);
 
        // The program runs indefinitely until you press a key
        while(!kbhit())
        {
 
                // Draw the road
                setfillstyle(SOLID_FILL,8);
                bar(150,0,470,500);
 
                // Draw the WHITE divider lines
                setfillstyle(SOLID_FILL,15);
                bar(310,0+i,320,50+i);
                bar(310,70+i,320,120+i);
                bar(310,140+i,320,190+i);
                bar(310,210+i,320,260+i);
                bar(310,280+i,320,330+i);
                bar(310,350+i,320,400+i);
                bar(310,420+i,320,470+i);
 
                delay(200);
 
                i=i+10;
 
                if(i >= 50) {
                        i=0;
                }
 
        }
 
        closegraph();
        getch();
}

Hope it helps!



Tagged with:  

2 Responses to A Simple Animation of a Road

  1. Nilesh says:

    Nice animation to the game….

  2. Yogita Patil says:

    helped me a lot..

Leave a Reply

Your email address will not be published. Required fields are marked *


*

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

  • Dipin Krishna

Archives

All entries, chronologically...

Read more:
To start with graphics programming
wheel
Moving Wheel using Mid-Point Circle algorithm and DDA Line algorithm

line
DDA Line Drawing Algorithm in C

MinMaxClose