A 2D Computer Graphics project developed to demonstrate fundamental graphics concepts through an interactive car-dodging game.
Project live on - " https://car-dodge-2d-game.vercel.app/ "
This project is a simple Car Dodge game developed using C and BGI graphics.h.
The player controls a green car and moves it left or right to avoid incoming traffic. The game demonstrates important Computer Graphics concepts such as 2D coordinates, geometric shapes, object movement, animation, color, and collision detection.
- ๐ Player Car โ Control the green car using keyboard input
- ๐ฃ๏ธ Road Animation โ Moving lane markings create a driving effect
- ๐ Traffic Cars โ Random traffic cars appear on different lanes
- ๐ฎ Keyboard Controls โ Use Left/Right Arrow keys or A/D
- ๐ Score System โ Score increases as the player survives
- ๐ฅ Collision Detection โ Detects when the player hits another car
- ๐ Restart Game โ Play again after a crash
- โก Increasing Difficulty โ Traffic speed increases as the game continues
- ๐จ Graphics Drawing โ Cars and road are created using basic shapes
The game uses X and Y coordinates to position the player car, traffic cars, road, and other objects on the screen.
- X-axis โ Controls horizontal position
- Y-axis โ Controls vertical position
Cars and road elements are created using basic graphical shapes such as:
- Rectangles
- Lines
- Filled shapes
These simple shapes are combined to create the game objects.
The player's X-position changes when the user presses the control keys.
Traffic cars and road markings move vertically by changing their Y-position.
The game continuously updates and redraws the scene to create movement.
Keyboard Input
โ
Move Player
โ
Move Traffic
โ
Update Road
โ
Update Score
โ
Draw Scene
โ
Check Collision
โ
Continue / Game Over
The program checks whether the player's car overlaps with an incoming traffic car.
If the two cars overlap, a collision is detected and the game ends.
| Key | Action |
|---|---|
| โฌ ๏ธ Left Arrow / A | Move Left |
| โก๏ธ Right Arrow / D | Move Right |
| โ ESC | Quit the Game |
The score increases continuously while the player survives.
The longer the player avoids traffic, the higher the score becomes.
- C โ Game programming
- BGI
graphics.hโ Computer graphics and drawing - conio.h โ Keyboard input
- dos.h โ Timing and delay functions
- Turbo C / WinBGIm โ Compatible environments for running the project
โโโ car_dodge.c
โโโ index.html
โโโ project-explanation.md
โโโ README.md
Start Game
โ
Control Player Car
โ
Avoid Traffic
โ
Traffic & Road Animation
โ
Increase Score
โ
Collision Detection
โ
Game Over
โ
Play Again / Exit
The project demonstrates how basic Computer Graphics concepts can be combined with programming logic to create an interactive 2D game.
| Member | GitHub |
|---|---|
| Devarsh | @dp0503 |
| Dhruv | @dhruvkabra05 |
| Krishna | @krishnaa0212 |
| Prishi | @Prishii17 |
| Vishesh | @visheshjainz |
Developed as an academic Computer Graphics project to demonstrate:
C Programming + Computer Graphics + Animation + Collision Detection