Car moving over a Hump

On July 27, 2012, in Animation, Drawing, by , Views : 26211


I wasn’t able(shortage of time) to make it a perfect one, but it looks kinda ok.

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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include<conio.h>
#include<dos.h>
#include<graphics.h>
 
void car(int x, int c, int i_f_y, int i_r_y)
{
    setcolor(c);
    line(x + 150, 100+i_r_y, x + 242, 100+i_f_y);
    ellipse(x + 242, 105+i_f_y, 0, 90, 10, 5);
    line(x + 150, 100+i_r_y, x + 120, 150+i_r_y);
    line(x + 252, 105+i_f_y, x + 280, 150+i_f_y);
    line(x + 100, 150+i_r_y, x + 320, 150+i_f_y);
    line(x + 100, 150+i_r_y, x + 100, 200+i_r_y);
    line(x + 320, 150+i_f_y, x + 320, 200+i_f_y);
    line(x + 100, 200+i_r_y, x + 110, 200+i_r_y);
    line(x + 320, 200+i_f_y, x + 310, 200+i_f_y);
    arc(x + 130, 200+i_r_y, 0, 180, 20);
    arc(x + 290, 200+i_f_y, 0, 180, 20);
    line(x + 270, 200+i_f_y, x + 150, 200+i_r_y);
    circle(x + 130, 200+i_r_y, 17);
    circle(x + 290, 200+i_f_y, 17);
 
}
 
 
void main()
{
    int gd = DETECT, gm = DETECT, i = -200;
    int iy=0, prv_iy=0, prv_iry=0;
    initgraph(&gd, &gm, "");
 
    ellipse(318, 220, 0, 180, 15, 8);
    line(0,220,640,220);
    setfillstyle(SOLID_FILL, RED);
    floodfill(318,215,15);
    car(i, 15,0,0);
 
    while (!kbhit()) {
		car(i++, 0,prv_iy,prv_iry);
		if(i>0 && i<50) {
			car(i,15,iy,0);
			prv_iy = iy;
			if(i>25){
				if(i%2==0) iy++;
			} else {
				if(i%2==0) iy--;
			}
		} else if(i>160 && i<210) {
			car(i,15,0,iy);
			prv_iry = iy;
			if(i>185){
				if(i%2==0) iy++;
			} else {
				if(i%2==0) iy--;
			}
		} else if(i>500) {
			break;
		} else {
			prv_iy = 0;
			prv_iry = 0;
			iy = 0;
			car(i, 15,0,0);
		}
		delay(20);
    }
}
/****************************************************************************/
/***********                WWW.CGLABPROGRAMS.COM                 ***********/
/****************************************************************************/

Download the code using the link below:

Please 'Like' or '+1' us to get the download link! (If you have already liked us on facebook, then like us either on G+ or twitter)



Hope, it helps! 🙂



Tagged with:  

One Response to Car moving over a Hump

  1. imran shaikh says:

    SUPER PROGRAM

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:
ellipse
Ellipse using Mid-Point Algorithm

wheel
Wheel

Flood Fill
Flood Fill

MinMaxClose