This is a small simulation of a road intersection I made using Rust and SDL2.
- Cars come from four directions: Top, Bottom, Left, Right.
- Traffic lights control the movement.
- Cars stop at red lights and move when it's green.
- You can manually add cars using arrow keys or randomly with the
Rkey.
↑Add car from Bottom↓Add car from Top←Add car from Right→Add car from LeftRAdd a random car from any directionEscQuit the simulation
- Rust
- SDL2
sdl2craterandcrate
- Cooldowns prevent cars from being spawned too fast.
- Cars avoid crashing and wait their turn at intersections.
That's it. Just a fun experiment with traffic logic and graphics in Rust :)
