So I'm making a traffic light programming game for Kajam 4. I thought it would be fun to look at the cars zoom by and respond to the lights you've so cunningly set up.
The first thing I wanted to set up are the roads. Because I plan to make a bunch of different levels, it would be neat to have a little road drawing algorithm, so I easily have various layouts.
First I started with a basic horizontal and vertical road, like this:
Now of course, the next thing was to try to have an intersection, because that's where the traffic lights come in. So there we go:
Hmm… that doesn't look entirely right, does it. So I added some special intersect drawing code:
Pretty sweet, if I may say so myself :D It doesn't just support 2 roads either:
And it also supports more than 2 lanes :D
And that's it for now. Next up: adding cars!