I was exploring the logic behind a racing game for the Vectrex, and wanted to create tracks automatically. That means creating a single line first which is the inner kerb of the track, then polygon offsetting to create the outer kerb of the track. Bumping into the walls should be detectable by the 'distance of a point from a line' algorithm from the mid-point line of the track.
High school maths, but I confess it took me a couple of hours to get it right. Track will scroll - so data structure is a cyclic array containing the track, and it will be drawn both forwards and backwards from where the player is, to simplify clipping.