0% found this document useful (0 votes)
33 views13 pages

CG Project

Uploaded by

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

CG Project

Uploaded by

Himesh Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

A MINI PROJECT REPORT ON

SIMPLE CAR ANIMATION

SUBMITTED TO THE SAVITRIBAI PHULE PUNE UNIVERSITY, PUNE


IN THE PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE
AWARD OF THE

BACHELOR OF ENGINEERING
(COMPUTER ENGINEERING)
BY

Himesh Patil (SE:B/39)

DEPARTMENT OF COMPUTER ENGINEERING

SHALAKA FOUNDATION’S
KEYSTONE SCHOOL OF ENGINEERING

NEAR HANDEWADI CHOWK, PUNE-412308

ACADEMIC YEAR 2024-25


SHALAKA FOUNDATION’S
KEYSTONE SCHOOL OF ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING

CERTIFICATE

This is to certify that the SPPU Curriculum-based Mini-Project report entitled

“SIMPLE CAR ANIMATION”


Submitted by

Himesh Patil (SE:B/39)

has satisfactorily completed the curriculum-based Mini-Project under the guidance


of Prof.Sonal Chanderi towards the fulfillment of 2nd year Computer Engineering ,
Academic Year 2024-25 of Savitribai Phule Pune University.

Prof. Sonal Prof. Sagar Rajebhosale Dr. Sandip Kadam


Chanderi
Mini Project Head of Department Principal
Guide

Place:
Date :
ACKNOWLEDGEMENT

It takes immense pleasure in presenting the complete Mini-Project report on 'Simple car animation'. I
extend my deepest gratitude to my guide, Prof. Sonal chanderi for their unwavering support and
guidance. I also wish to thank my Head of Department, Prof. Sagar Rajebhosale, for his invaluable
insights. My heartfelt appreciation goes to Dr. Sandeep Kadam, Principal of our institution, and Prof.
Y.R. Soman,Director, for their encouragement and cooperation throughout the Mini-Project. This Mini-
Project would not have been possible without the support of our faculty members, dear parents, and
friends.

Himesh Patil (SE:B/39)


INDEX
Sr.no Topic Page No.
1 Certificate 1
2 Abstract 4
3 System Specification 5
4 Introduction 6
5 Implementation 7
8
6 Source code
7 Output 9
8 Application 10
Abstract
This report presents the implementation of a 2D simple car animation program using C++ as part of the
Computer Graphics subject. The program demonstrates the use of basic computer graphics principles to
create a visual simulation of a car moving along a road. By utilizing the C++ programming language and
the graphics library, the program introduces key concepts such as 2D transformations, animation
techniques, and graphical rendering. The Bank 2D Simple Car Animation project serves as both an
educational tool and a practical application of computer graphics algorithms, showcasing fundamental
graphic drawing, object movement, and real-time animation.

The primary objective of the program is to animate a simple 2D car model that moves along a road,
simulating realistic motion through the use of translation and other transformations. The car's movement is
created by updating its position in small increments, ensuring smooth motion. The animation also includes
basic elements of a road scene, such as the road itself, road markings, and a static background, providing
context and enhancing the visual appeal of the animation. The system allows the car to move continuously
across the screen, simulating a driving experience, and can be further extended to incorporate additional
features such as user interaction, speed control, or collision detection.

The program uses the C++ graphics library (such as `graphics.h`, or any modern 2D graphics library like
SFML, SDL, or OpenGL) to render the various components of the animation. By utilizing the concepts of
coordinate manipulation and updating the screen at regular intervals, the car’s movement is achieved
through translation operations. This helps demonstrate how computer graphics systems manage object
positioning, movement, and rendering in real time. The movement of the car is driven by a loop that
updates its coordinates on the screen, and each frame of the animation is rendered sequentially, making
the car appear to move smoothly from left to right (or any desired direction) across the screen.

The core components of the program include:

1. Car Object Representation: The car is represented using basic geometric shapes such as rectangles
and circles, which are drawn and transformed to simulate motion.

2. Road Representation: The road and its markings are implemented as static visual elements,
providing the context in which the car moves.

3. Movement Simulation: The car's movement is simulated by adjusting its position incrementally,
updating the coordinates each time the program redraws the scene. This incremental updating
creates the illusion of continuous motion.

4. Animation Loop: An animation loop continuously updates the car’s position and redraws the scene
at regular intervals, achieving a fluid animation.

The implementation of the Bank 2D Simple Car Animation project provides students with hands-on
experience in creating basic animations, understanding the underlying mechanics of animation, and
exploring fundamental computer graphics principles. By interacting with the program, users can observe
the effects of various transformations, including translation and scaling, in the context of a 2D graphical
environment.

This project also has potential extensions. Future enhancements could involve adding more realistic car
motion (such as acceleration or deceleration), background changes, interactive controls, or even
incorporating more complex graphics techniques like sprite animations or texture mapping. Additionally,
the program could be extended to simulate a more complex road system, include obstacles, or simulate
various weather conditions, offering opportunities for further learning and development in the field of
computer graphics.
System Specification
The 2D Simple Car Animation program is a graphical simulation developed in C++ that aims to
demonstrate basic animation techniques, object movement, and rendering in the context of computer
graphics. The program simulates the motion of a car moving along a road, creating a visually engaging
scene by utilizing fundamental graphics principles such as translation, object rendering, and animation
loops. The program serves as a learning tool for students studying computer graphics, helping them
understand the fundamental aspects of graphical programming, real-time rendering, and object
transformations.

System Overview

The system consists of a 2D graphical environment where a simple car object moves along a road. The
car’s motion is represented using basic geometric shapes, such as rectangles for the car body and circles
for the wheels, which are manipulated to create the illusion of movement. The car is animated by adjusting
its position along a pre-defined path, such as a horizontal road, while the background (the road and the
environment) remains static. The car is rendered on the screen with each frame of the animation updated
incrementally to simulate continuous motion. The primary goal of the system is to teach animation
principles and object manipulation in 2D space.

System Requirements

Hardware Requirements:

• A computer with at least 4 GB RAM


• A graphics card supporting 16-bit or higher color depth
• Minimum of 500 MB free disk space for assets and development tools

Software Requirements:

• Operating System: Ubuntu


• Compiler: GCC (GNU Compiler Collection) or any compatible IDE that supports graphics.h
• graphics.h library, typically bundled with the SDL.

Dependencies:

• SDL(Simple DirectMedia layer) files, required for rendering graphics


INTRODUCTION
Computer graphics is an essential discipline within computer science that focuses on creating visual
content through computational methods. This field encompasses various applications, including video
games, simulations, data visualization, and interactive media. A key component of computer graphics is
the ability to create dynamic animations that enhance user engagement and experience.

In this project, we develop a simple car animation using the graphics.h library in C++. This library offers
an accessible way for beginners to explore computer graphics, enabling the creation of 2D shapes and
animations without the complexity of modern graphics frameworks.

The car animation exemplifies several fundamental concepts in computer graphics:

1. Drawing and Rendering: The project illustrates how to draw basic geometric shape rectangles for
the car body and circles for the wheels using the graphics functions provided by the library.
Rendering these shapes onto the screen highlights the core principles of graphical representation.

2. Motion and Animation: Smooth motion is achieved by continuously updating the car's position
within a loop. This approach demonstrates animation techniques, including clearing the screen,
redrawing elements, and managing frame rates to ensure fluid transitions.

3. Background Integration: The animation features a dynamic background with elements such as
trees and clouds, contributing to a more immersive experience. This aspect highlights layering in
graphics, where different elements are rendered at various depths to create a sense of realism.

4. User Interaction Potential: Although the current implementation is automatic, there is scope for
future enhancements that allow user control over the car’s movement, further increasing
interactivity.
Implementation
1. Environment Setup:
• Install GCC or an appropriate IDE that supports graphics.h.
• Ensure that the BGI files are correctly set up to facilitate graphics rendering.

2. Asset Creation:
• Design 2D images for the car, road, trees, and clouds using graphics software.
• Convert these designs into simple geometric shapes or bitmap images suitable for rendering
in graphics.h

3. Basic Animation Logic:


• Initialize the graphics mode using initgraph().
• Define initial positions and properties for the car and background elements.
• Implement a loop that continuously updates the car’s position and redraws the scene.

4. Rendering the Scene:


• Use functions such as setcolor(), rectangle(), and circle() to draw the car and background
elements.
• Implement a basic scrolling background effect to enhance the animation’s realism.

5. User Interaction (Optional):


• Include keyboard inputs to control the speed or direction of the car.

6. Optimization:
• Ensure smooth transitions by using appropriate delay functions, such as delay(), to control
frame updates.
SOURCE CODE
#include <graphics.h>
#include <iostream>
using namespace std;
void drawCar(int x, int y)
{
rectangle(x, y, x + 100, y + 50);
rectangle(x + 20, y - 20, x + 80, y);
line(x + 30, y - 20, x + 30, y);
line(x + 70, y - 20, x + 70, y);
circle(x + 25, y + 50, 15);
circle(x + 75, y + 50, 15);
}
void drawBackground()
{
line(0, 400, getmaxx(), 400);
for (int i = 100; i <= getmaxx(); i += 200)
{
rectangle(i, 300, i + 20, 400);
circle(i + 10, 270, 40);
}
circle(100, 100, 30);
circle(130, 100, 30);
circle(160, 100, 30);
circle(300, 150, 30);
circle(330, 150, 30);
circle(360, 150, 30);
}
int main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm,const_cast<char*>("/"));
int x = 0, y = 350;
while(true)
{
cleardevice();
drawBackground();
drawCar(x, y);
x += 10;
if (x > getmaxx())
{
x = -100;
}
delay(100);
}
closegraph();
OUTPUT
APPLICATION
1. Simulation and Visualization in Automotive Engineering
• Automobile Design and Testing: A 2D car animation can serve as an initial step in vehicle
simulation for automotive design and engineering. It can be used to simulate basic movements and
interactions of cars, such as their response to acceleration, deceleration, turning, and other
maneuvers.
o Engineers and designers can use this kind of animation to test how different car models or
components behave in certain conditions, without having to rely on physical prototypes. It
serves as a basic visualization tool before progressing to more complex 3D simulations.
o In the future, this can be expanded with more advanced simulations such as collision
detection, vehicle dynamics, and safety features.

2. Educational Tool for Learning Computer Graphics


• The 2D Car Animation program is a valuable tool for teaching and learning computer graphics
concepts in an educational setting.
o Basic Animation Techniques: It helps students understand how object transformation,
coordinate systems, and motion are handled in computer graphics. Concepts such as linear
interpolation, frame-by-frame rendering, and event handling are often part of the learning
experience.
o Libraries and Frameworks: By working with the C++ program, students can get hands-on
experience with popular graphics libraries like OpenGL, SDL, or SFML, learning how to
manipulate graphics in a 2D space and develop basic animation systems.
o The project can be expanded to teach more advanced topics such as collision detection,
pathfinding algorithms, or camera movements in both 2D and 3D space.

3. Game Development - Basic Racing or Driving Games


• The 2D Car Animation can be used as a starting point for the development of 2D racing games or
driving simulators.
o Game Prototyping: Developers can use this animation as a prototype for basic car physics
and movement. The animation can serve as the basis for more complex games where
players can control the car’s speed, direction, and interaction with the environment.
o Game Mechanics: It can simulate basic aspects like acceleration, turning, road-bound
movement, and even the interaction between cars or other obstacles. This lays the
groundwork for more advanced features, such as collision handling, scoring, and level
design.
o Developers could later integrate elements like AI for competing cars, checkpoints, or
power-ups into the animation, eventually turning it into a simple driving game.

4. Virtual Reality and Augmented Reality Prototyping


• While primarily used for simple 2D visuals, the basic 2D car animation could be a stepping stone
towards creating more sophisticated Virtual Reality (VR) or Augmented Reality (AR) driving
experiences.
o Prototyping: The simple car animation in 2D can serve as an early prototype in VR/AR
development, enabling designers to create 3D models and environments with more
advanced graphics, simulations, and physics.
o Movement and Pathfinding: The animation can simulate how vehicles would move in a
virtual environment, helping to test and refine the pathfinding algorithms or collision
detection systems that will be integrated into more complex VR driving simulations.
o Such a system can eventually be scaled up to create virtual driving experiences for training
purposes or games in VR environments, enhancing user immersion.
13

You might also like