0% found this document useful (0 votes)
76 views15 pages

Moving Cycle Project in C Graphics

This document describes a micro project report on a moving cycle using computer graphics. It includes: 1. An introduction to the project describing the use of graphics functions to create the output of a moving cycle. 2. Details of the header files used like graphics.h for drawing shapes and delay functions. 3. The functions used - line, circle, rectangle, delay, cleardevice, and closegraph. 4. The approach of drawing the cycle body, wheels, road, and stones, and changing the position in a loop to create movement. 5. A flowchart and code sample to implement the moving cycle.

Uploaded by

RIHAN PATHAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views15 pages

Moving Cycle Project in C Graphics

This document describes a micro project report on a moving cycle using computer graphics. It includes: 1. An introduction to the project describing the use of graphics functions to create the output of a moving cycle. 2. Details of the header files used like graphics.h for drawing shapes and delay functions. 3. The functions used - line, circle, rectangle, delay, cleardevice, and closegraph. 4. The approach of drawing the cycle body, wheels, road, and stones, and changing the position in a loop to create movement. 5. A flowchart and code sample to implement the moving cycle.

Uploaded by

RIHAN PATHAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

MAHARASHTRA STATE BOARD OF TECHNICAL

EDUCATION, MUMBAI

A MICRO PROJECT REPORT


ON

“MOVING CYCLE”

CGR MICRO-PROJECT

Submitted by:-
[Link] chaitanya 2215600344
[Link] avdhut 2115600191
[Link] harshad 2215600339
[Link] rihan 2115600172
Under Guidance
[Link]
DEPARTMENT OF COMPUTER ENGINEERING
Ashok Institute Of Engineering
&Techonology,Polytechnic,Ashoknagar(2022-2023)
Ashok Gramin Shikshan Sanstha’s
Ashok Institute of Engineering & Technology Polytechnic Ashoknagar
Tal-Shrirampur, Dist-Ahmednagar, Pin Code-413717

CERTIFICATE
This is to certify that the Project work Entitled

“MOVING CYCLE”
SUBMITTED BY

[Link] chaitanya 2215600344


[Link] avdhut 2115600191
[Link] harshad 2215600339
[Link] rihan 2115600172

As partial fulfillment of Diploma course in Computer


Engineering under the Maharashtra State Board of Technical
Education, Mumbai during academic year 2022-2023.
The said work has been assessed by us and we are
satisfied that the same is up to the standard envisaged for the
level of the course, and that the said work may be presented
to the examiner.

Guide Principal HOD

Prof. [Link] Prof. A. P. Shinde Prof. V. D. Ghogre

Institute code:-1560(DTE CODE:-D5395)


MAHARASHTRA STATE BOARD OF TECHNICAL
EDUCATION, MUMBAI (M.S.)

CERTIFICATE

[Link] chaitanya 2215600344


[Link] avdhut 2115600191
[Link] harshad 2215600339
[Link] rihan 2115600172
Student Of Computer Engineering Was Examined
In
Micro Project Entitled

“MOVING CYCLE”

On / /202
Department of Computer Engineering
ASHOK INSTITUTE OF ENGINEERING & TECHNOLOGY
POLYTECHNIC,ASHOKNAGAR-413717

SHRIRAMPUR (M.S.)2022-2023

ACKNOWLEDGEMENT
It has been a privilege for me to be associated with Prof. S .S. Tawade ,
my guide during this dissertation work. I have been greatly benefited by their
valuable suggestions and ideas. It is with great pleasure that I express my deep
sense of gratitude to her for their guidance, constant encouragement, for their
kindness, moral support and patience throughout this work.

Prof. Ghogare V. D., Head of Department of Computer Engineering, has


been indeed a great source of inspiration for all of us in the campus, so it gives me
an immense pleasure in expressing my indebtedness to his for him kindness and
moral support.

At outset, I take opportunity to express my sincere gratitude to

Prof. A. P. Shinde., Principal for giving me an opportunity to pursue my studies


for the present work.

I am heartily thankful to all staff of Applied Science Engineering


Department from Ashok Polytechnic, Ashoknagar for giving me valuable support.

Finally, I would like to express my deep, incomparable appreciation and


gratitude to my family members for their constant spiritual support and
encouragement to pursue the higher technical education.

Date: / /202

Place: Ashoknagar

Name of Student

[Link] chaitanya 2215600344


[Link] avdhut 2115600191
[Link] harshad 2215600339
[Link] rihan 2115600172
MICRO PROJECT

COMPUTER GRAPHICS

TOPIC:- MOVING CYCLE USING COMPUTER GRAPHICS

SUBMITTED BY : -

[Link] chaitanya 2215600344


[Link] avdhut 2115600191
[Link] harshad 2215600339
[Link] rihan 2115600172

INDEX
[Link] TOPIC PAGE NO.
1 INTRODUCTION 1

2 HEADER FILES 2

3 FUNCTIONS AND FUNCTION USED 3


4 APPROCH 4
5 FLOWCHART 5
6 CODE 6
7 OUTPUT 7
8 CONCLUSION 8
9 REFERENCE 9

INTRODUCTION
This is our computer graphics project. Our topic is moving cycle. We have
used various Graphics function in this project to execute the output. This project
is simple and Interesting. We have explained various header files and graphics
function used in [Link] have also mentioned the output of the moving
cycle.

In C graphics, the graphics.h functions are used to draw different shapes


like circles, rectangles, etc, display text(any message) in a different
format (different fonts and colors). By using the functions in the
header graphics.h, programs, animations, and different games can also be made.
In this article, let’s discuss how to draw a moving cycle in C using graphics.

1.

HEADER FILES
There are various header files used in program :

➢ #include conio.h

➢ #include iostream.h

➢ #include graphics.h

➢ #include doc.h

1 . conio.h

: - Conio.h is a header files used for function related to console input/output.


:- Conio.h has many inbuilt library function.

:- There are many function declared In conio.h like

1) Getch(); 2 ) Clrscr();

2. iostream.h

:- It is used to perform input and output operation using function like 1) Cout(); 2 )
Cin();

3. #include graphics.h
:- The graphics.h function is used to draw different shapes like circle, rectangle, Etc,
display test(any message) in a different format ( different fonts and Colors) by using the
function in the header files graphics.h, program, Animation and different games can also
be made.

4. #include doc.h
:- Is a header file of c language . thi library has functions that are used for handeling
interrups, produsing sound date and time function etc.

2.

FUNCTIONS AND FUNCTION USED


C
 LINE

 CIRCLE

 RECTANGLE

 DELAY

 CLEARDEVICE

 CLOSEGRAPH

 line(x1, y1, x2, y2): It is a function provided by Graphics.h header file to


draw a line. Here x1, y1 is the first coordinates of the line, and x2, y2 are
the second coordinates of the line respectively.

 circle(x, y, r): It is a function provided by graphics.h  header file to draw a


circle. The x, y are the center points of the circle and r is the radius of the
circle.

 rectangle(X1, Y1, X2, Y2): It is employed in the creation of a rectangle. The


rectangle must be drawn using the coordinates of the left top and right
bottom corners. The X-coordinate and Y-coordinate of the top left
corner are X1 and Y1 and the X-coordinate and Y-coordinate of the bottom
right corner are X2 and Y2 respectively.

 delay(n): It is used to hold the program for a specific time period. Here n is
the number of seconds you want to hold the program.

 cleardevice(): It is used to clear the screen in graphic mode. It sets the


position of the cursor to its initial position, that is, (0, 0) coordinates.

 closegraph(): It is used to close the graph.

3.
APPROCH
 Pass the three arguments to the initgraph() function to initialize the
graphics driver and graphics mode.

 Create the upper body of the cycle by drawing lines.

 Create the wheels of the cycle by drawing circles and choose the
coordinates so that the wheels aligned

 just below the upper body of the cycle

 The next step Is to create the road by drawing lines and stone by drawing
rectangles.

 Choose the coordinates so that the cycle is just above the road

 Change the cycle’s position using a loop continuously so that it appears to


be moving on the

4.
FLOWCHART

5.
CODE FOR MOVING CYCLE

// C++ program to draw the moving


// cycle using computer graphics

#include
#include
#include
#include
// Driver code
Int main()
{
Int gd = DETECT, gm, I, a;
// Path of the program
Initgraph(&gd, &gm, “C:\\TURBOC3\\BGI”program);
// 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 sec
Delay(10);
// Clear the screen
Cleardevice();
}
Getch();
// Close the graph
Closegraph();
}

6.
OUTPUT OF OUR PROGRAM
7.
REFFERENCES
 [Link]

 [Link]
computer-graphics-programming-in-c-cpp/

9.

CONCLUSION
This program demonstrate a moving cycle using this six graphics function.

 LINE
 CIRCLE
 RECTANGLE
 DELAY
 CLEARDEVICE
 CLOSEGRAPH

8.

Common questions

Powered by AI

Projects like the moving cycle significantly enhance educational understanding of computer graphics by translating theoretical concepts into practical experiences. They require the application of knowledge about coordinate systems, graphical functions, and animation principles, encouraging students to engage with concepts actively rather than passively absorbing information. This hands-on approach nurtures problem-solving skills, as students must troubleshoot and refine code to achieve desired outcomes. Furthermore, the excitement of seeing visual results fosters motivation and deepens comprehension, making learning both effective and enjoyable. Practical projects bridge the gap between theory and practice, consolidating academic learning with practical application .

Challenges in coding a moving graphical object in C include handling complex coordinates calculations, synchronizing movement speed, and debugging graphical output. Accurate calculation and consistent updating of coordinates are essential to avoid distorted or erratic motion. Incremental testing, where parts of the code are tested frequently, can mitigate errors. Synchronizing speed can be challenging due to varied processing power; using functions like `delay()` ensures uniform pacing. Debugging graphical output requires methodically checking each drawing step and the logic flow, possibly using visual flowcharts for clarity. Solutions include leveraging debugging tools, thorough planning, and leveraging resources like online forums for community help .

The primary graphics functions used in the moving cycle project include `line()`, `circle()`, `rectangle()`, `delay()`, `cleardevice()`, and `closegraph()`. The `line()` function is used to draw straight edges of the cycle and the road. The `circle()` function creates the cycle's wheels. `rectangle()` helps in drawing the stone on the road. `delay()` introduces pauses to control the animation speed, allowing the cycle to appear moving progressively. `cleardevice()` clears the screen in each loop iteration to draw the next frame, creating movement fluidity. Finally, `closegraph()` shuts down the graphics system, completing the program execution. Together, these functions interactively develop the animation flow, creating a cohesive moving cycle visual .

The use of a loop in the moving cycle program is of paramount significance as it enables continuous redrawing of cycle positions, thereby simulating motion over time. By iterating through successive frames where the positional values of graphical elements (such as lines and circles representing the cycle) are incremented, the cycle appears to move forward smoothly. Without the loop, each frame would be static, requiring manual intervention to update positions. The loop integrates dynamic elements like `delay()` for pacing, `cleardevice()` for clearing previous frames, and `getch()` and `closegraph()` for program termination. Thus, the loop is integral to replicating real-life continuous motion within the animation .

The `delay()` function in C graphics can be crucial for enhancing visual animations by introducing controlled pauses in the program execution, which allows individual frames of an animation to be displayed for a specified time. By fine-tuning the delay, developers can adjust the speed of the animation to achieve desired effects, such as slow motion or fast-paced movements. In the context of the moving cycle project, `delay()` is used to pace the movement of the cycle, ensuring smooth transitions as it progresses along the road, preventing it from appearing too fast or abrupt .

The `cleardevice()` function is crucial in graphic animations like the moving cycle as it resets the screen to a blank state, clearing all previous drawings. This preemptive clearing ensures no residual images from prior frames remain, which could conflict with or obscure the current frame's visuals. By invoking `cleardevice()` in each iteration of the drawing loop, it prepares a clean canvas for rendering the subsequent frame, thereby facilitating smooth transitions between frames and maintaining visual clarity throughout the animation .

The approach for constructing a moving cycle in a graphical C application involves several key steps that build the animation incrementally. Firstly, the `initgraph()` function initializes the graphics driver and mode, setting up the environment for drawing. The cycle's upper body is created using lines, while the wheels are constructed by drawing circles, strategically placed to align below the body, forming the complete cycle shape. A road and stone are depicted using lines and rectangles respectively, set at coordinates to simulate a ground level. The movement is simulated by altering the cycle's position in a loop, creating the illusion of movement across the road. In each iteration, a delay function pauses execution to control animation speed, followed by `cleardevice()` to refresh the screen, and `closegraph()` at the end to terminate the graphical session .

The header files in C programming play a crucial role in creating graphical applications by providing predefined functions and operations. For instance, `graphics.h` is used to draw shapes like circles and rectangles, as well as to display text in various formats. This is fundamental in creating animations and graphical applications. The `conio.h` header file supports console input/output operations, essential for interacting with the device during the execution of a graphical program. Moreover, `iostream.h` facilitates input and output using streams, which is crucial for dynamic data handling in graphics. Thus, these header files collectively allow for the drawing and manipulation of graphics necessary for projects like the moving cycle .

A flowchart is a critical tool in developing the moving cycle project as it provides a visual representation of the algorithmic steps required for implementation. It outlines the sequence of actions, including initialization, drawing operations, and looping constructs, offering a clear pathway from start to finish. This clarity aids in both understanding the process flow and in code debugging or modification, ensuring all essential phases like drawing, movement, and termination are planned accurately. Flowcharts help visualize the logic, reducing errors and enhancing communication among developers .

Coordinate systems in graphical programming are pivotal in positioning elements accurately within a defined space. In the moving cycle project, coordinates dictate where each line, circle, and rectangle appears on the screen, effectively constructing the cycle and its environment. Precise coordinate choices ensure correct alignment of the cycle's parts, such as positioning wheels under the frame and placing the cycle correctly above the road. Inaccurate coordinates could result in distorted images, misalignments, or visual inconsistency, compromising the animation's realism and fluidity. Hence, a coherent coordinate system is essential for maintaining drawing accuracy and realism .

You might also like