C/C++ Program to Build a Moving Cycle Animation Using Graphics Programming

Here, You will know about “C/C++ Program to Build a Moving Cycle Animation Using Graphics Programming“. Below, We will discuss how to do the task using this tutorial? Let’s move.

C/C++ Program to Build a Moving Cycle Animation Using Graphics Programming

C/C++ Program to Build a Moving Cycle Animation Using Graphics Programming

Program Code

// C++ program to draw the moving
// cycle using computer graphics

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

// Driver code
int main()
{
	int gd = DETECT, gm, i, a;

	// Path of the program
	initgraph(&gd, &gm, "C:\TURBOC3\BGI");

	// Move the cycle
	for (i = 0; i < 600; i++) {
		// Upper body of cycle
		line(50 + i, 405, 100 + i, 405);
		line(75 + i, 375, 125 + i, 375);
		line(50 + i, 405, 75 + i, 375);
		line(100 + i, 405, 100 + i, 345);
		line(150 + i, 405, 100 + i, 345);
		line(75 + i, 345, 75 + i, 370);
		line(70 + i, 370, 80 + i, 370);
		line(80 + i, 345, 100 + i, 345);

		// Wheel
		circle(150 + i, 405, 30);
		circle(50 + i, 405, 30);

		// Road
		line(0, 436, getmaxx(), 436);

		// Stone
		rectangle(getmaxx() - i, 436,
				650 - i, 431);

		// Stop the screen for 10 secs
		delay(10);

		// Clear the screen
		cleardevice();
	}

	getch();

	// Close the graph
	closegraph();
}

Final Words

We hope this article helps you to learn “C/C++ Program to Build a Moving Cycle Animation Using Graphics Programming”. If you have any doubts about this topic then please let us know via the comment section. We will help you. Share this article with other C/C++ developers.

Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment