Skip to content

Conversation

@iamKaviB
Copy link
Contributor

🚗 City Traffic Simulator

An interactive real-time city traffic simulation built entirely with HTML5 Canvas and JavaScript.
Watch cars move through intersections, traffic lights change dynamically, and roads come alive with your adjustments.

💡 Control traffic density, light timing, and car speed — or even create your own traffic jam!


🌆 Overview

The City Traffic Simulator visualizes urban traffic flow through animated cars and intersections governed by traffic lights.
This project blends mathematical motion, canvas animation, and interactive UI controls to simulate real-world scenarios like rush hours and traffic jams.


✨ Features

  • 🚦 Dynamic Traffic Lights — independent red/yellow/green cycles with adjustable duration
  • 🚗 AI-like Car Motion — cars automatically move and stop at red lights
  • 🏙️ Procedural City Layout — generated grid roads and buildings
  • ⚙️ Control Panel to customize:
    • Car speed
    • Light duration
    • Traffic density
  • 🚨 Create Traffic Jam button — spawns cars and sets all lights to red
  • Add / Remove Cars manually
  • 📊 Live Stats Dashboard — shows car count and average speed
  • 🖥️ Responsive Canvas — automatically resizes to your screen
  • Optimized Animations using requestAnimationFrame

🧰 Technologies Used

Component Technology
Graphics HTML5 Canvas
Programming Vanilla JavaScript (ES6)
Styling CSS3 (Flexbox, Neon Dashboard Design)
Animation requestAnimationFrame
UI Custom sliders and glowing buttons

🚀 Getting Started

1️⃣ Clone the repository

git clone https://github.com/yourusername/Hacktoberfest2025.git
cd Hacktoberfest2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant